AxesDivider.append_axes创建的轴的边界框不正确?
创始人
2024-09-28 11:01:14
0

在使用AxesDivider.append_axes方法创建轴时,如果轴的边界框不正确,可以尝试以下

  1. 使用AxesDivider.set_locator方法来设置轴的位置和尺寸,以确保边界框正确。例如:
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import Divider, Size

fig = plt.figure(figsize=(6, 6))

# 创建一个分隔器
divider = Divider(fig, (0.2, 0.2, 0.7, 0.7), [Size.Fixed(0.2), Size.Fixed(0.2)])

# 在分隔器上添加轴
ax1 = divider.append_axes((1.0, 1.0, 1.0, 1.0))
ax2 = divider.append_axes((1.0, 1.0, 1.0, 1.0))

# 设置轴的位置和尺寸
ax1_locator = divider.new_locator(nx=0, ny=1)
ax2_locator = divider.new_locator(nx=1, ny=1)
ax1.set_axes_locator(ax1_locator)
ax2.set_axes_locator(ax2_locator)

# 绘制图形
ax1.plot([1, 2, 3], [1, 2, 3])
ax2.plot([1, 2, 3], [3, 2, 1])

plt.show()
  1. 使用Axes.set_position方法来调整轴的位置和尺寸。例如:
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import Divider, Size

fig = plt.figure(figsize=(6, 6))

# 创建一个分隔器
divider = Divider(fig, (0.2, 0.2, 0.7, 0.7), [Size.Fixed(0.2), Size.Fixed(0.2)])

# 在分隔器上添加轴
ax1 = divider.append_axes((1.0, 1.0, 1.0, 1.0))
ax2 = divider.append_axes((1.0, 1.0, 1.0, 1.0))

# 调整轴的位置和尺寸
ax1.set_position([0.25, 0.25, 0.5, 0.5])
ax2.set_position([0.5, 0.5, 0.5, 0.5])

# 绘制图形
ax1.plot([1, 2, 3], [1, 2, 3])
ax2.plot([1, 2, 3], [3, 2, 1])

plt.show()

这些方法可以确保轴的边界框正确,并且在使用AxesDivider.append_axes方法创建轴时也更加灵活。

相关内容

热门资讯

开挂辅助!微乐小程序辅助,德州... 开挂辅助!微乐小程序辅助,德州局hhpoker(透视)开挂辅助工具(有挂辅助);1、让任何用户在无需...
开挂辅助!雀友会潮汕麻将开挂辅... 开挂辅助!雀友会潮汕麻将开挂辅助,wepoker永久免费脚本(透视)开挂辅助软件(的确有挂);1、很...
辅助开挂!博弈麻友圈辅助,we... 辅助开挂!博弈麻友圈辅助,we poker游戏下(透视)开挂辅助插件(有挂教程);亲,有的,ai轻松...
开挂辅助!九九山城辅助,红龙p... 开挂辅助!九九山城辅助,红龙poker辅助(透视)开挂辅助插件(有挂规律);是一款可以让一直输的玩家...
辅助开挂!拼十app辅助,we... 辅助开挂!拼十app辅助,wepoker透视有吗(透视)开挂辅助工具(有挂分析);拼十app辅助软件...
辅助开挂!hhpoker有没有... 辅助开挂!hhpoker有没有作比,智星德州有脚本吗(透视)开挂辅助插件(有挂教程);1.hhpok...
辅助开挂!丽水都莱大菠萝辅助,... 辅助开挂!丽水都莱大菠萝辅助,wepoker永久免费脚本(透视)开挂辅助插件(有挂透明挂);丽水都莱...
辅助开挂!闽游互动辅助器,we... 辅助开挂!闽游互动辅助器,werplan辅助软件(透视)开挂辅助安装(发现有挂);1、让任何用户在无...
开挂辅助!微信小程序挂机辅助,... 开挂辅助!微信小程序挂机辅助,德普之星辅助工具如何设置(透视)开挂辅助插件(有挂攻略);超受欢迎的微...
辅助开挂!广西老友麻将有挂吗,... 辅助开挂!广西老友麻将有挂吗,wepoker俱乐部辅助器(透视)开挂辅助插件(有挂分析);小薇(透视...