9951 explained code solutions for 126 technologies


python-matplotlibHow to show minor grid lines


import matplotlib.pyplot as plt
plt.plot([1,2,10,6,15,3,4,2,5,1,7,3,4])
plt.yscale('log')
plt.grid(b=True, which='major', color='#444',linestyle='--')
plt.grid(b=True, which='minor', color='#ccc',linestyle='--')
plt.show()ctrl + c
import matplotlib.pyplot as plt

loads Matplotlib module to use plotting capabilities

.plot(

plot specified data

.grid(

add and configure grid

which

specify which grid type to configure (major or minor)

color

grid line color

linestyle

grid line style

.show()

render chart in a separate window


How to show minor grid lines, python matplotlib

Usage example

import matplotlib.pyplot as plt
plt.plot([1,2,10,6,15,3,4,2,5,1,7,3,4])
plt.yscale('log')
plt.grid(b=True, which='major', color='#444',linestyle='--')
plt.grid(b=True, which='minor', color='#ccc',linestyle='--')
plt.show()