Skip to content

Commit 5bf4dd5

Browse files
committed
added new logic to deal with the new image parameter (iplot, plot)
1 parent dbbad22 commit 5bf4dd5

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

plotly/offline/offline.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
__PLOTLY_OFFLINE_INITIALIZED = False
3333

34+
__IMAGE_FORMATS = ['jpeg', 'svg', 'webp', 'svg']
35+
3436

3537
def download_plotlyjs(download_url):
3638
warnings.warn('''
@@ -248,6 +250,10 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
248250
display(HTML(plot_html))
249251

250252
if image:
253+
if image not in __IMAGE_FORMATS:
254+
raise ValueError('The image parameter takes only the following'
255+
'format types: `png`, `jpeg`, `webp`, `svg`')
256+
# if the check passes then download script injection will commence.
251257
warnings.warn('For higher resolution images and more export '
252258
'options, consider making requests to the '
253259
'Plotly image servers. Type help(\'py.image\') '
@@ -376,6 +382,11 @@ def plot(figure_or_data,
376382
plotly_js_script = ''
377383

378384
if image:
385+
if image not in __IMAGE_FORMATS:
386+
raise ValueError('The image parameter takes only the
387+
'following format types: `png`, `jpeg`, '
388+
'`webp`, `svg`')
389+
# if the check passes then download script is injected.
379390
warnings.warn('For higher resolution images and more export '
380391
'options, consider making requests to the '
381392
'Plotly image servers. Type help(\'py.image\') '
@@ -484,10 +495,8 @@ def plot_mpl(mpl_fig, resize=False, strip_style=False,
484495
the format of the image to be downloaded, if we choose to download an
485496
image. This parameter has a default value of None indicating that no
486497
image should be downloaded.
487-
format (default='png') -- Specifies the format of the image to be
488-
downloaded if `downlowad_image` is True.
489498
image_filename (default='plot_image') -- Sets the name of the file your
490-
image will be saved to. The extension should not be included.
499+
image will be saved to. The extension should not be included.
491500
image_height (default=600) -- Specifies the height of the image in `px`.
492501
image_width (default=800) -- Specifies the width of the image in `px`.
493502

0 commit comments

Comments
 (0)