Skip to content

Mpl updated #31

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

Merged
merged 3 commits into from
Jun 17, 2014
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Added try-except block to buffer errors from bad 'update' arguments.
(also added documentation for update)
  • Loading branch information
theengineear committed Jun 13, 2014
commit 300bab317bed1f571ae9d7fc0f64ef3b67a2eb90
26 changes: 22 additions & 4 deletions plotly/plotly/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,24 @@ def iplot_mpl(fig, resize=True, strip_style=False, update=None, **plot_options):
Keyword arguments:
resize (default=True) -- allow plotly to choose the figure size
strip_style (default=False) -- allow plotly to choose style options
update (default=None) -- update the resulting figure with an 'update'
dictionary-like object resembling a plotly 'Figure' object

Additional keyword arguments:
plot_options -- run help(plotly.plotly.iplot)

"""
fig = tools.mpl_to_plotly(fig, resize=resize, strip_style=strip_style)
if update:
update_fig = tools.get_valid_graph_obj(update, 'Figure')
fig.update(update_fig)
try:
update_fig = tools.get_valid_graph_obj(update, 'Figure')
except exceptions.PlotlyGraphObjectError as err:
err.add_note("Your update figure could not be properly converted "
"into a plotly 'Figure' graph object.")
err.prepare()
raise
else:
fig.update(update_fig)
return iplot(fig, **plot_options)


Expand All @@ -235,15 +244,24 @@ def plot_mpl(fig, resize=True, strip_style=False, update=None, **plot_options):
Keyword arguments:
resize (default=True) -- allow plotly to choose the figure size
strip_style (default=False) -- allow plotly to choose style options
update (default=None) -- update the resulting figure with an 'update'
dictionary-like object resembling a plotly 'Figure' object

Additional keyword arguments:
plot_options -- run help(plotly.plotly.plot)

"""
fig = tools.mpl_to_plotly(fig, resize=resize, strip_style=strip_style)
if update:
update_fig = tools.get_valid_graph_obj(update, 'Figure')
fig.update(update_fig)
try:
update_fig = tools.get_valid_graph_obj(update, 'Figure')
except exceptions.PlotlyGraphObjectError as err:
err.add_note("Your update figure could not be properly converted "
"into a plotly 'Figure' graph object.")
err.prepare()
raise
else:
fig.update(update_fig)
return plot(fig, **plot_options)


Expand Down