我正在尝试在我的轴范围之外添加一条小线,我希望在以后的阶段将其用作高度定制的图例。但是,使用axes.hlines
会更改轴的xlim,即使我指定了transform = axes.transAxes
。xlim的设置似乎使hline的坐标包含在datacoordinate范围内。只是,这些坐标是轴坐标,而不是数据坐标
下面是一个简单的工作示例:
import numpy as np
import matplotlib.pyplot as plt
x_data = np.random.rand(10)+10
y_data = np.random.rand(10)
fig, ax = plt.subplots()
ax.scatter(x_data,y_data)
ax.hlines(0.5,1.1,1.2, transform = ax.transAxes, clip_on = False)
通过ax.hlines
命令更改XLIM的结果:
当ax.hlines
被注释掉时,您会得到:
目前没有回答
相关问题 更多 >
编程相关推荐