Alexander Soare
Alexander Soare

Reputation: 3267

How to make plot options apply to all axes in a figure

Say I have something like

fig, ax = plt.subplots(2, 2, figsize=(10,10))
ax = ax.flatten()
ax[0].plot # ....
ax[2].plot # ....
ax[2].plot # ....
ax[3].plot # ....
plt.axis('scaled')

The plt.axis only applies to the last plot. What's the per axis equivalent?

And while I'm at it, more generally, matplotlib has been driving me insane this way for years. I have never found a clear way to go from plt.method to ax.method without having to dig deep in the docs. For instance there's plt.title then ax.set_title for some reason. Any pointers in general for this (teach a person how to fish).

Upvotes: 1

Views: 343

Answers (1)

BigBen
BigBen

Reputation: 50162

From the pyplot.axis docs:

'scaled': Set equal scaling (i.e., make circles circular) by changing dimensions of the plot box. This is the same as ax.set_aspect('equal', adjustable='box', anchor='C'). Additionally, further autoscaling will be disabled.

Upvotes: 1

Related Questions