2024-05-13 01:04:04 发布
网友
我有个情节是这样的:
很明显,左边和右边是浪费空间,所以我设置
plt.axis('tight')
但这给了我这样的情节:
xlim现在看起来很不错,但是ylim对于情节来说太紧凑了。
我想知道,在我的情况下,是否只能将axis(tight)设置为x轴?
axis(tight)
所以情节可能是这样的:
我当然可以通过
plt.gca().set_xlim(left=-10, right=360)
但恐怕这不是一个非常优雅的解决方案。
您想使用^{} class中matplotlib的^{}方法。
使用函数式API,可以使用
plt.autoscale(enable=True, axis='x', tight=True)
或者如果您使用的是面向对象的API
ax = plt.gca() # only to illustrate what `ax` is ax.autoscale(enable=True, axis='x', tight=True)
为了完整性,axiskwarg可以采用'x'、'y',或者'both',其中默认值为'both'。
axis
'x'
'y'
'both'
您想使用^{} class 中matplotlib的^{} 方法。
使用函数式API,可以使用
或者如果您使用的是面向对象的API
为了完整性,
axis
kwarg可以采用'x'
、'y'
,或者'both'
,其中默认值为'both'
。相关问题 更多 >
编程相关推荐