File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change 1313 " from open_atmos_jupyter_utils import show_plot\n " ,
1414 " \n " ,
1515 " fig = pyplot.figure()\n " ,
16- " show_plot()"
16+ " show_plot(fig=fig )"
1717 ],
1818 "id" : " 840cd46405eb9d0e" ,
1919 "outputs" : [
Original file line number Diff line number Diff line change 88from open_atmos_jupyter_utils .temporary_file import TemporaryFile
99
1010
11- def show_plot (filename = None , inline_format = 'svg' ):
11+ def show_plot (filename = None , fig = pyplot , inline_format = 'svg' ):
1212 """ the missing click-to-save-as-pdf-or-svg button for matplotlib/Jupyter
1313 (use instead of *.show()) """
14- link = save_and_make_link (filename )
14+ link = save_and_make_link (fig , filename )
1515 select_figure_formats (InteractiveShell .instance (), {inline_format })
1616 pyplot .show ()
1717 display (link )
1818
1919
20- def save_and_make_link (filename = None ):
20+ def save_and_make_link (fig , filename = None ):
2121 """ saves a figure as pdf and returns a Jupyter display()-able click-to-download widget """
2222 temporary_files = [
2323 TemporaryFile (suffix = suffix , filename = (
@@ -27,5 +27,5 @@ def save_and_make_link(filename=None):
2727 for suffix in ('.pdf' , '.svg' )
2828 ]
2929 for temporary_file in temporary_files :
30- pyplot .savefig (temporary_file .absolute_path , bbox_inches = 'tight' )
30+ fig .savefig (temporary_file .absolute_path , bbox_inches = 'tight' )
3131 return HBox ([temporary_file .make_link_widget () for temporary_file in temporary_files ])
You can’t perform that action at this time.
0 commit comments