python - matplotlib 中 figure.add_axes() 中的 left 和 bottom 有什么作用?
问题描述
你好,我目前正在学习matplotlib。我刚刚了解了数字和add_axes()
方法。对于该add_axes()
方法,您传入一个包含[left, bottom, width, height]
.
显然,width
并且height
控制了图形的宽度和高度,但是做什么left
和bottom
做什么呢?
这是我的add_axes()
->axes = figure.add_axes([0.1, 0.1, 0.6, 0.6])
我一直在改变left
and bottom
,但情节上没有任何改变。我在 上阅读了 matplotlib 文档figure.add_axes()
,但它没有解释什么left
和bottom
做了什么。
谢谢!
解决方案
mpl.figure.add_axes 的描述和示例
mpl.figure.add_axes(rect, projection=None, polar=False, **kwargs)
将轴添加到当前图窗或指定轴。
来自matplotlib mpl.figure.ad_axes 方法文档:
rect:浮点序列。新轴的尺寸 [left, bottom, width, height]。所有数量都是图形宽度和高度的分数。
- left = 距离图形左侧多远(如 ax 值)
- bottom = 离图形底部多远(如 ay 值)
这是一个快速的谷歌搜索
这是一个例子:
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']]
推荐阅读
- xstate - 如何从 xstate 中的状态获取所有可能的转换
- python-3.x - 将python输出复制到excel文件
- php - 如何在多个文件中调用@extends?
- ansible - 尝试动态生成数组 Jinja2
- python - 'DataFrame' 对象没有属性
- android - (Android Studio) 无法为 SD 卡上的文件创建 MediaPlayer
- c# - 设计模式建议 - 从 TXT 读取数据
- java - 在 docker 中使用 Java 执行本机应用程序(本机应用程序需要额外的本机库)
- python - 有没有办法将先前的值连续存储并在满足新条件时更改?
- c# - 如何复制内存
到 byte[] 中的特定偏移量