I would like to render a ggplot2 style filled grid, a la
(source: had.co.nz)
I haven't been able to find any online resources that deal with styling the grid in such a way. Do I have to resort to doing something like plotting my own rectangular patches?
Edit: after trying Chris' solution, I have written a script to help make matplotlib graphs look like ggplot2 if anyone is interested.
http://messymind.net/making-matplotlib-look-like-ggplot/
The following code uses matplotlib.pyplot.grid
to turn on a grid and set the grid properties (line colour, style and width) and then uses plt.gca().patch.set_facecolor('0.8')
to change the axes color (I'm not sure if there is, but there must be convenience function to do this). The argument to patch.set_facecolor
is any matplotlib colour.
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()
The result is
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With