Skip to content

Commit 5c9dac2

Browse files
committed
revert fig removal
1 parent f6ee92e commit 5c9dac2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

examples/notebook_vars.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
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": [

open_atmos_jupyter_utils/show_plot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
from 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])

0 commit comments

Comments
 (0)