Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to choose if a figure of Matplotlib has to be closed #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions mplleaflet/_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
trim_blocks=True, lstrip_blocks=True)

def fig_to_html(fig=None, template='base.html', tiles=None, crs=None,
epsg=None, embed_links=False, float_precision=6):
epsg=None, embed_links=False, float_precision=6, close_mpl=True):
"""
Convert a Matplotlib Figure to a Leaflet map

Expand Down Expand Up @@ -59,6 +59,8 @@ def fig_to_html(fig=None, template='base.html', tiles=None, crs=None,
the final html.
float_precision : int, default 6
The precision to be used for the floats in the embedded geojson.
close_mpl : bool, default True
Close the instance of a figure of Matplotlib.

Note: only one of 'crs' or 'epsg' may be specified. Both may be None, in
which case the plot is assumed to be longitude / latitude.
Expand All @@ -83,7 +85,7 @@ def fig_to_html(fig=None, template='base.html', tiles=None, crs=None,
dpi = fig.get_dpi()

renderer = LeafletRenderer(crs=crs, epsg=epsg)
exporter = Exporter(renderer)
exporter = Exporter(renderer, close_mpl=close_mpl)
exporter.run(fig)

attribution = _attribution + ' | ' + tiles[1]
Expand Down