Here is the explanation of how the code works:
- fig, ax = plt.subplots(1,2) defines the figure with two axis objects on the same row. Since it is only one row with two plots, ax is a one-dimensional vector, so we will access them with ax[0] and ax[1].
- line = lines.Line2D([0*cm, 1.5*cm], [0*cm, 2.5*cm], lw=2, color='black', axes=ax[0]) plots a black line segment on axis ax[0], with line width 2, and input data, in centimeters.
- Similarly, t = text.Text(3*cm, 2.5*cm, 'text label', ha='left', va='bottom', axes=ax[0]) defines a text label object to ax[0] at the specified position (3, 2.5) in centimeters with the left alignment horizontally and a bottom alignment vertically.
It should be noted that Matplotlib does not support sharing ...