How to plot fastai genereted figure from matplotlib?

I am using fastai library without jupyter notebook, so in that case how to plot figures for instance learn.recorder.plot() from matplotlib ? and also is there any flexibility to lodge output in custom logger.

Thank you very much.

Regards,
Dhiren

You can use libsixel and a compatible terminal to see the plots in terminal, otherwise using return_fig=True will return you the figure and you can do whatever you want with it.

2 Likes

Could you please give an example in code? In course-v3, lesson 1, I’m trying to save the figure from plot_top_losses by doing:

interp.plot_top_losses(9, figsize=(15,11), return_fig=True)

Nothing gets saved in the directory that I’m running my code in or in the path_img location. I recall someone else suggesting using matplotlib’s savefig as an alternative but I was unsuccessful. Please advise. Thanks!

Update: Success! I was able to figure it out by doing something like…
fig1 = interp.plot_top_losses(9, figsize=(15,11), return_fig=True)
fig1.savefig(“cats-dogs-res34-top-loss” + ‘.jpg’, dpi=1000, bbox_inches=‘tight’)

2 Likes