...

Library - Matplotlib

Back to Course

Lesson Description


Lession - #507 matplotlib Grid


grid in matplotlib

The grid(>
capacity of axes object sets visibility of lattice inside the figure to on or off. You can likewise show major/minor (or both>
ticks of the framework. Moreover tone, linestyle and linewidth properties can be set in the framework(>
work.

    import matplotlib.pyplot as plt
import numpy as np
fig, axes = plt.subplots(1,3, figsize = (12,4>
>
x = np.arange(1,11>
axes[0].plot(x, x**3, 'g',lw=2>
axes[0].grid(True>
axes[0].set_title('default grid'>
axes[1].plot(x, np.exp(x>
, 'r'>
axes[1].grid(color='b', ls = '-.', lw = 0.25>
axes[1].set_title('custom grid'>
axes[2].plot(x,x>
axes[2].set_title('no grid'>
fig.tight_layout(>
plt.show(>