|
31 | 31 |
|
32 | 32 | __PLOTLY_OFFLINE_INITIALIZED = False
|
33 | 33 |
|
| 34 | +__IMAGE_FORMATS = ['jpeg', 'svg', 'webp', 'svg'] |
| 35 | + |
34 | 36 |
|
35 | 37 | def download_plotlyjs(download_url):
|
36 | 38 | warnings.warn('''
|
@@ -248,6 +250,10 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
|
248 | 250 | display(HTML(plot_html))
|
249 | 251 |
|
250 | 252 | 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. |
251 | 257 | warnings.warn('For higher resolution images and more export '
|
252 | 258 | 'options, consider making requests to the '
|
253 | 259 | 'Plotly image servers. Type help(\'py.image\') '
|
@@ -376,6 +382,11 @@ def plot(figure_or_data,
|
376 | 382 | plotly_js_script = ''
|
377 | 383 |
|
378 | 384 | 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. |
379 | 390 | warnings.warn('For higher resolution images and more export '
|
380 | 391 | 'options, consider making requests to the '
|
381 | 392 | 'Plotly image servers. Type help(\'py.image\') '
|
@@ -484,10 +495,8 @@ def plot_mpl(mpl_fig, resize=False, strip_style=False,
|
484 | 495 | the format of the image to be downloaded, if we choose to download an
|
485 | 496 | image. This parameter has a default value of None indicating that no
|
486 | 497 | image should be downloaded.
|
487 |
| - format (default='png') -- Specifies the format of the image to be |
488 |
| - downloaded if `downlowad_image` is True. |
489 | 498 | 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. |
491 | 500 | image_height (default=600) -- Specifies the height of the image in `px`.
|
492 | 501 | image_width (default=800) -- Specifies the width of the image in `px`.
|
493 | 502 |
|
|
0 commit comments