pyfolio icon indicating copy to clipboard operation
pyfolio copied to clipboard

Cant save figures to files

Open Rudra-J opened this issue 3 years ago • 0 comments

Problem Description

I am unable to save these pyfolio plots to files locally on my pc

def fig2img(self,fig):
        buf = io.BytesIO()
        fig.savefig(buf)
        buf.seek(0)
        img = Image.open(buf)
        return img

Please provide the full traceback:

plt.figure(figsize=(15, 6))
fig=pyfolio.plot_rolling_sharpe(pnl_df_eod['returns'])
img = self.fig2img(fig)
ppath=os.path.join(path,'rolling_sharpe.png')
img.save(ppath)

Please provide any additional information below: The error that is displayed is {'Axes' object has no attribute 'savefig'}

Versions

  • Pyfolio version:
  • Python version:
  • Pandas version:
  • Matplotlib version:

Rudra-J avatar Jul 04 '23 19:07 Rudra-J