简体   繁体   中英

What does left and bottom in figure.add_axes() do in Matplotlib?

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!

Description and example of mpl.figure.add_axes

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.

  • left = how far from the left of the figure (like ax value)
  • bottom = how far from the bottom of the figure (like ay value)

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']]

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM