gpt4 book ai didi

python - 使用 Matplotlib 和 iPython,如何将 x 和 y 轴限制重置为自动缩放?

转载 作者:太空狗 更新时间:2023-10-29 21:29:18 25 4
gpt4 key购买 nike

使用 matplotlib 和 iPython,我有一堆要查看的图(一个接一个)。有些图只包含从 0 到 1 的值,有些图包含数百万的值。

使用以下方法设置 y 轴限制后:

ylim((.7,1))

我希望能够重置它以自动设置限制(就像以前那样)。我无法找到正确的方法。

最佳答案

ax = plt.gca()  # get the current axes
ax.relim() # make sure all the data fits
ax.autoscale() # auto-scale
# only needed mpl < 1.5
# ax.figure.canvas.draw_idle() # re-draw the figure

关于python - 使用 Matplotlib 和 iPython,如何将 x 和 y 轴限制重置为自动缩放?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18795172/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com