繁体   English   中英

缩放图后如何保存图

[英]How to save plot after the plot is zoomed

最近几天,我在保存matplotlib图时遇到了一个问题,这是在代码可以正常工作的三天之前,并且通过代码进行了更改来保存绘图,但是现在更改(缩放的绘图)没有保存,而是保存了是在显示绘图时进行的任何更改都不能使用save命令反映出来,不知道为什么吗?

    ax = pd.rolling_mean(dataToPlot_plot[startTime:endTime][['plotValue']],mar).plot(linestyle='-', linewidth=3,  markersize=9, color='#FECB00')
            ax.legend().set_visible(False)
    plt.show()#showing the plot
    fig = ax.get_figure()
    fig.set_size_inches(12, 6)#setting the size of the plot, to fix in the PDF file
    fig.savefig('graph1.jpg')#saving the plot

即使我调用函数,也不会保存新更改的图...

    def callmeto_plot()
            ax = pd.rolling_mean(dataToPlot_plot[startTime:endTime][['plotValue']],mar).plot(linestyle='-', linewidth=3,  markersize=9, color='#FECB00')
            ax.legend().set_visible(False)
            plt.show()#showing the plot
            fig = ax.get_figure()

            return fig

    fig = callmeto_plot()
    fig.set_size_inches(12, 6)
    fig.savefig('graph1.jpg')

如何通过代码保存绘图(缩放后的图)?
注意:我注意到绘图窗口的外观也发生了变化,
1绘制窗口外观之前
2现在绘制窗口外观
所有绘图窗口配置按钮都从底部移到顶部,此更改是否只影响绘图或编码? 请帮我解决这个问题...
提前致谢。

您可以将所有绘图更改代码plt.show()上方,然后从弹出窗口中手动保存图形。 左下方最右边的图标会将当前图形保存为当前显示的状态

更好的是,您可以使用plt.axis([xStart, xFinish, yBottom, yTop])ax.set_xlim(), ax.set_ylim

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM