Saving plots (AxesSubPlot) generated from python pandas with matplotlib's savefig

后端 未结 5 2088
Happy的楠姐
Happy的楠姐 2020-12-02 07:18

I\'m using pandas to generate a plot from a dataframe, which I would like to save to a file:

dtf = pd.DataFrame.from_records(d,columns=h)
fig = plt.figure()
         


        
5条回答
  •  情话喂你
    2020-12-02 07:52

    The gcf method is depricated in V 0.14, The below code works for me:

    plot = dtf.plot()
    fig = plot.get_figure()
    fig.savefig("output.png")
    

提交回复
热议问题