@@ -163,33 +163,8 @@ def plot(figure_or_data, validate=True, **plot_options):
163163 False: do not open plot in the browser, but do return the unique url
164164
165165 """
166- if isinstance (figure_or_data , dict ):
167- figure = figure_or_data
168- elif isinstance (figure_or_data , list ):
169- figure = {'data' : figure_or_data }
170- else :
171- raise exceptions .PlotlyError ("The `figure_or_data` positional argument "
172- "must be either `dict`-like or "
173- "`list`-like." )
174- if validate :
175- try :
176- tools .validate (figure , obj_type = 'Figure' )
177- except exceptions .PlotlyError as err :
178- raise exceptions .PlotlyError ("Invalid 'figure_or_data' argument. "
179- "Plotly will not be able to properly "
180- "parse the resulting JSON. If you "
181- "want to send this 'figure_or_data' "
182- "to Plotly anyway (not recommended), "
183- "you can set 'validate=False' as a "
184- "plot option.\n Here's why you're "
185- "seeing this error:\n \n {0}"
186- "" .format (err ))
187- if not figure ['data' ]:
188- raise exceptions .PlotlyEmptyDataError (
189- "Empty data list found. Make sure that you populated the "
190- "list of data objects you're sending and try again.\n "
191- "Questions? support@plot.ly"
192- )
166+ figure = tools .return_figure_from_figure_or_data (figure_or_data , validate )
167+
193168 for entry in figure ['data' ]:
194169 for key , val in list (entry .items ()):
195170 try :
0 commit comments