How it works...

Here is the explanation for the preceding code:

  • fig = plt.figure() defines the figure object.
  • ax = AxisArtist.Axes(fig, [0.1, 0.1, 0.8, 0.8]) defines the axes of the AxisArtist class at given coordinates, starting from the left, through to the bottom, width, and height, respectively.
  • fig.add_axes(ax) adds an axes object to the figure.
  • ax.axis["right", "top"].set_visible(False) sets top and right axes (spines) as invisible. You can set this for each of the axes separately also.
  • ax.set_xlabel("X Axis") sets the label of the x axis as "X Axis".
  • ax.axis["bottom"].label.set_rotation(30) rotates the x axis label by 30 degrees counterclockwise.
  • ax.set_ylabel("Y Axis") sets the label of the y axis label as "Y Axis".
  • ax.axis["y=1"] ...

Get Matplotlib 3.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.