Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 86bbcc5

Browse files
committed
allow mpl-users to update figures with plot/iplot with 'update' dict.
1 parent 7b71be9 commit 86bbcc5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

plotly/plotly/plotly.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def plot(figure_or_data, validate=True, **plot_options):
195195
raise exceptions.PlotlyAccountError(res['error'])
196196

197197

198-
def iplot_mpl(fig, resize=True, strip_style=False, **plot_options):
198+
def iplot_mpl(fig, resize=True, strip_style=False, update=None, **plot_options):
199199
"""Replot a matplotlib figure with plotly in IPython.
200200
201201
This function:
@@ -215,10 +215,13 @@ def iplot_mpl(fig, resize=True, strip_style=False, **plot_options):
215215
216216
"""
217217
fig = tools.mpl_to_plotly(fig, resize=resize, strip_style=strip_style)
218+
if update:
219+
update_fig = tools.get_valid_graph_obj(update, 'Figure')
220+
fig.update(update_fig)
218221
return iplot(fig, **plot_options)
219222

220223

221-
def plot_mpl(fig, resize=True, strip_style=False, **plot_options):
224+
def plot_mpl(fig, resize=True, strip_style=False, update=None, **plot_options):
222225
"""Replot a matplotlib figure with plotly.
223226
224227
This function:
@@ -238,6 +241,9 @@ def plot_mpl(fig, resize=True, strip_style=False, **plot_options):
238241
239242
"""
240243
fig = tools.mpl_to_plotly(fig, resize=resize, strip_style=strip_style)
244+
if update:
245+
update_fig = tools.get_valid_graph_obj(update, 'Figure')
246+
fig.update(update_fig)
241247
return plot(fig, **plot_options)
242248

243249

0 commit comments

Comments
 (0)