R 绘图自动设置 x 和 y 限制,以在数据和轴之间留出一些空间。我想知道 matplotlib 是否有办法自动执行相同的操作。如果没有,是否有一个好的公式或“经验法则”来说明 R 如何设置其轴限制?
在 matplotlib 中,您可以通过设置来实现这一点margins http://matplotlib.org/api/axes_api.html?highlight=xlim#matplotlib.axes.Axes.margins
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.margins(0.04)
data = range(1, 11)
ax.plot(data, 'wo')
plt.savefig('margins.png')
然而,似乎没有一个 rc 参数可以自动获取它。
更新 4/2013
现在可以在 matplotlib 中为边距添加 rc 参数master https://github.com/matplotlib/matplotlib/pull/1908(感谢@tcaswell)。
所以它应该与下一个 matplotlib 版本一起使用(当前版本是 1.2.1)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)