How to fill matplotlib grid?

I would like to make a grid filled with ggplot2 style, a la this
(source: had.co.nz )

I could not find a single online resource that would deal with mesh styling in this way. Should I resort to creating something like creating my rectangular patches?

Change: after trying to solve Chris, I wrote a script that will help make matplotlib graphs look like ggplot2, if anyone is interested.

http://messymind.net/making-matplotlib-look-like-ggplot/

+6
source share
1 answer

The following code uses matplotlib.pyplot.grid to turn on the grid and set the grid properties (line color, style and width), and then uses plt.gca().patch.set_facecolor('0.8') to change the color of the axes (I don't I am sure that there is, but for this there should be a convenient function). The argument to patch.set_facecolor is any matplotlib color .

 import numpy import matplotlib.pyplot as plt x = numpy.random.rand(10) x = numpy.random.rand(10) plt.plot(x, y, 'o') plt.grid(True, color='w', linestyle='-', linewidth=2) plt.gca().patch.set_facecolor('0.8') plt.show() 

Result

Figure generated by the code above

+6
source

Source: https://habr.com/ru/post/921464/


All Articles