August 2017
Beginner to intermediate
334 pages
8h 22m
English
Grids can be added by calling pyplot.grid(). By default, grid lines will be added at major tick marks. As in other line features, pyplot.grid() takes in parameters such as linewidth (lw), linestyle (ls), and color (c):
import numpy as npimport matplotlib.pyplot as plt# Prepare 100 evenly spaced numbers from 0 to 200evens = np.linspace(0,200,100)# Plot a square curveplt.plot(evens,evens**2,label = 'x^2')# Adding grid linesplt.grid()plt.legend()plt.show()
Here you see the default grid lines extending from axis ticks:

In the preceding example, while the grid lines help us locate the coordinates in different locations, they have also ...
Read now
Unlock full access