Reputation: 435
Hello, I am currently learning matplotlib. I have just learnt about figures and the add_axes()
method. For the add_axes()
method, you pass in a list containing [left, bottom, width, height]
.
Obviously, width
and height
controls the width and height of the graph, but what does left
and bottom
do?
Here is my add_axes()
-> axes = figure.add_axes([0.1, 0.1, 0.6, 0.6])
I keep changing left
and bottom
, but nothing on the plot is changing. I read the matplotlib documentation on figure.add_axes()
, but it did not explain what left
and bottom
did.
Thank you!
Upvotes: 2
Views: 3445
Reputation: 740
mpl.figure.add_axes(rect, projection=None, polar=False, **kwargs)
Adds an axis to the current figure or a specified axis.
From the matplotlib mpl.figure.ad_axes method documentation:
rect: sequence of floats. The dimensions [left, bottom, width, height] of the new Axes. All quantities are in fractions of figure width and height.
Here is a quick google search
Here is an example:
fig, ax1 = plt.subplots(figsize=(12,8))
ax2 = fig.add_axes([0.575,0.55,0.3,0.3])
ax1.grid(axis='y', dashes=(8,3), color='gray', alpha=0.3)
for ax in [ax1, ax2]:
[ax.spines[s].set_visible(False) for s in ['top','right']]
Upvotes: 2