Now we can learn about some features that we can add to plots, and some features to control them better.
In the previous images, we saw that the background of the figure was completely blank. While it might be nice for some plots, there are situations where having a reference system would improve the comprehension of the plot—for example with multiline plots. We can add a grid to the plot by calling the
grid() function; it takes one parameter, a Boolean value, to enable (if
True ) or disable (if
False) the grid:
In : import matplotlib.pyplot as plt In : import numpy as np In : x = np.arange(1, 5) In : plt.plot(x, x*1.5, x, x*3.0, x, x/3.0) Out: [<matplotlib.lines.Line2D object at 0x8fcc20c>, <matplotlib.lines.Line2D ...