@@ -217,16 +217,19 @@ def iplot_mpl(fig, resize=True, strip_style=False, update=None, **plot_options):
217
217
218
218
"""
219
219
fig = tools .mpl_to_plotly (fig , resize = resize , strip_style = strip_style )
220
- if update :
220
+ if update and isinstance ( update , dict ) :
221
221
try :
222
- update_fig = tools .get_valid_graph_obj (update , 'Figure' )
222
+ fig .update (update )
223
+ fig .validate ()
223
224
except exceptions .PlotlyGraphObjectError as err :
224
- err .add_note ("Your update figure could not be properly converted "
225
- "into a plotly 'Figure' graph object." )
225
+ err .add_note ("Your updated figure could not be properly validated." )
226
226
err .prepare ()
227
227
raise
228
- else :
229
- fig .update (update_fig )
228
+ elif update :
229
+ raise exceptions .PlotlyGraphObjectError (
230
+ "'update' must be dictionary-like and a valid plotly Figure "
231
+ "object. Run 'help(plotly.graph_objs.Figure)' for more info."
232
+ )
230
233
return iplot (fig , ** plot_options )
231
234
232
235
@@ -252,16 +255,19 @@ def plot_mpl(fig, resize=True, strip_style=False, update=None, **plot_options):
252
255
253
256
"""
254
257
fig = tools .mpl_to_plotly (fig , resize = resize , strip_style = strip_style )
255
- if update :
258
+ if update and isinstance ( update , dict ) :
256
259
try :
257
- update_fig = tools .get_valid_graph_obj (update , 'Figure' )
260
+ fig .update (update )
261
+ fig .validate ()
258
262
except exceptions .PlotlyGraphObjectError as err :
259
- err .add_note ("Your update figure could not be properly converted "
260
- "into a plotly 'Figure' graph object." )
263
+ err .add_note ("Your updated figure could not be properly validated." )
261
264
err .prepare ()
262
265
raise
263
- else :
264
- fig .update (update_fig )
266
+ elif update :
267
+ raise exceptions .PlotlyGraphObjectError (
268
+ "'update' must be dictionary-like and a valid plotly Figure "
269
+ "object. Run 'help(plotly.graph_objs.Figure)' for more info."
270
+ )
265
271
return plot (fig , ** plot_options )
266
272
267
273
0 commit comments