October 2018
Beginner to intermediate
676 pages
18h 30m
English
The following code block draws two plots, one with centimeters and the other with inches, to demonstrate the difference between two units of measurement:
fig, ax = plt.subplots(1,2)
line = lines.Line2D([0*cm, 1.5*cm], [0*cm, 2.5*cm], lw=2, color='black', axes=ax[0])t = text.Text(3*cm, 2.5*cm, 'text label', ha='left', va='bottom', axes=ax[0])
ax[0].add_line(line)ax[0].add_artist(t)ax[0].set_xlim(-1*cm, 10*cm)ax[0].set_ylim(-1*cm, 10*cm)ax[0].xaxis.set_units(cm)ax[0].yaxis.set_units(cm)ax[0].grid(True)
Read now
Unlock full access