@@ -185,10 +185,9 @@ def _plot_html(figure_or_data, show_link, link_text, validate,
185
185
186
186
return plotly_html_div , plotdivid , width , height
187
187
188
-
189
188
def iplot (figure_or_data , show_link = True , link_text = 'Export to plot.ly' ,
190
- validate = True , image = False , format = 'png' ,
191
- _width = 800 , _height = 600 , filename = 'plot' ):
189
+ validate = True , image = None , filename = 'plot_image' , image_width = 800 ,
190
+ image_height = 600 ):
192
191
"""
193
192
Draw plotly graphs inside an IPython notebook without
194
193
connecting to an external server.
@@ -211,22 +210,23 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
211
210
has become outdated with your version of
212
211
graph_reference.json or if you need to include
213
212
extra, unnecessary keys in your figure.
214
- image (default=False) -- If True, the image of the current plot
215
- will be downloaded.
216
- format (default='png') -- Specifies the format of the image to be
217
- downloaded if `downlowad_image` is True .
213
+ image (default=None |'png' |'jpeg' |'svg' |'webp') -- This parameter sets
214
+ the format of the image to be downloaded, if we choose to download an
215
+ image. This parameter has a default value of None indicating that no
216
+ image should be downloaded .
218
217
filename (default='plot') -- Sets the name of the file your image
219
218
will be saved to. The extension should not be included.
220
- _height (default=600) -- Specifies the height of the image in `px`.
221
- _width (default=800) -- Specifies the width of the image in `px`.
219
+ image_height (default=600) -- Specifies the height of the image in `px`.
220
+ image_width (default=800) -- Specifies the width of the image in `px`.
222
221
223
222
Example:
224
223
```
225
224
from plotly.offline import init_notebook_mode, iplot
226
225
init_notebook_mode()
227
226
iplot([{'x': [1, 2, 3], 'y': [5, 2, 7]}])
228
- # We can also download an image of the plot by setting `image=True`
229
- iplot([{'x': [1, 2, 3], 'y': [5, 2, 7]}], image=True)
227
+ # We can also download an image of the plot by setting the image to the
228
+ format you want ie: `image='png'`
229
+ iplot([{'x': [1, 2, 3], 'y': [5, 2, 7]}], image='png')
230
230
```
231
231
"""
232
232
if not __PLOTLY_OFFLINE_INITIALIZED :
@@ -264,11 +264,12 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
264
264
'downloadimage(\' {format}\' , {height}, {width}, '
265
265
'\' {filename}\' );}}'
266
266
'</script>'
267
- ).format (format = format , width = _width , height = _height ,
268
- filename = filename , plot_id = plotdivid )
267
+ ).format (format = format , width = image_width ,
268
+ height = image_height , filename = filename ,
269
+ plot_id = plotdivid )
269
270
# allow time for the plot to draw
270
271
import time
271
- time .sleep (1 )
272
+ time .sleep (0. 1 )
272
273
# inject code to download an image of the plot
273
274
display (HTML (script ))
274
275
@@ -278,8 +279,8 @@ def plot(figure_or_data,
278
279
validate = True , output_type = 'file' ,
279
280
include_plotlyjs = True ,
280
281
filename = 'temp-plot.html' , auto_open = True ,
281
- image = False , image_filename = 'plot_image' , format = 'png ' ,
282
- _width = 800 , _height = 600 ):
282
+ image = None , image_filename = 'plot_image' ,
283
+ image_width = 800 , image_height = 600 ):
283
284
""" Create a plotly graph locally as an HTML document or string.
284
285
285
286
Example:
@@ -288,9 +289,10 @@ def plot(figure_or_data,
288
289
import plotly.graph_objs as go
289
290
290
291
plot([go.Scatter(x=[1, 2, 3], y=[3, 2, 6])], filename='my-graph.html')
291
- # We can also download an image of the plot by setting `image=True`
292
+ # We can also download an image of the plot by setting the image parameter
293
+ # to the image format we want
292
294
plot([go.Scatter(x=[1, 2, 3], y=[3, 2, 6])], filename='my-graph.html'
293
- image=True )
295
+ image='jpeg' )
294
296
```
295
297
More examples below.
296
298
@@ -328,14 +330,14 @@ def plot(figure_or_data,
328
330
auto_open (default=True) -- If True, open the saved file in a
329
331
web browser after saving.
330
332
This argument only applies if `output_type` is 'file'.
331
- image (default=False) -- If True, the image of the current plot
332
- will be downloaded.
333
- format (default='png') -- Specifies the format of the image to be
334
- downloaded if `downlowad_image` is True .
333
+ image (default=None |'png' |'jpeg' |'svg' |'webp') -- This parameter sets
334
+ the format of the image to be downloaded, if we choose to download an
335
+ image. This parameter has a default value of None indicating that no
336
+ image should be downloaded .
335
337
image_filename (default='plot_image') -- Sets the name of the file your image
336
338
will be saved to. The extension should not be included.
337
- _height (default=600) -- Specifies the height of the image in `px`.
338
- _width (default=800) -- Specifies the width of the image in `px`.
339
+ image_height (default=600) -- Specifies the height of the image in `px`.
340
+ image_width (default=800) -- Specifies the width of the image in `px`.
339
341
"""
340
342
if output_type not in ['div' , 'file' ]:
341
343
raise ValueError (
@@ -392,7 +394,8 @@ def plot(figure_or_data,
392
394
'downloadimage(\' {format}\' , {height}, {width}, '
393
395
'\' {filename}\' );}}'
394
396
'</script>'
395
- ).format (format = format , width = _width , height = _height ,
397
+ ).format (format = format , width = image_width ,
398
+ height = image_height ,
396
399
filename = image_filename , plot_id = plotdivid )
397
400
else :
398
401
script = ''
@@ -432,8 +435,8 @@ def plot_mpl(mpl_fig, resize=False, strip_style=False,
432
435
verbose = False , show_link = True , link_text = 'Export to plot.ly' ,
433
436
validate = True , output_type = 'file' , include_plotlyjs = True ,
434
437
filename = 'temp-plot.html' , auto_open = True ,
435
- image = False , image_filename = 'plot_image' , format = 'png ' ,
436
- _height = 600 , _width = 800 ):
438
+ image = None , image_filename = 'plot_image' ,
439
+ image_height = 600 , image_width = 800 ):
437
440
"""
438
441
Convert a matplotlib figure to a Plotly graph stored locally as HTML.
439
442
@@ -477,14 +480,16 @@ def plot_mpl(mpl_fig, resize=False, strip_style=False,
477
480
auto_open (default=True) -- If True, open the saved file in a
478
481
web browser after saving.
479
482
This argument only applies if `output_type` is 'file'.
480
- image (default=False) -- If True, the image of the current plot
481
- will be downloaded.
483
+ image (default=None |'png' |'jpeg' |'svg' |'webp') -- This parameter sets
484
+ the format of the image to be downloaded, if we choose to download an
485
+ image. This parameter has a default value of None indicating that no
486
+ image should be downloaded.
482
487
format (default='png') -- Specifies the format of the image to be
483
488
downloaded if `downlowad_image` is True.
484
489
image_filename (default='plot_image') -- Sets the name of the file your
485
490
image will be saved to. The extension should not be included.
486
- _height (default=600) -- Specifies the height of the image in `px`.
487
- _width (default=800) -- Specifies the width of the image in `px`.
491
+ image_height (default=600) -- Specifies the height of the image in `px`.
492
+ image_width (default=800) -- Specifies the width of the image in `px`.
488
493
489
494
Example:
490
495
```
@@ -500,21 +505,22 @@ def plot_mpl(mpl_fig, resize=False, strip_style=False,
500
505
501
506
plot_mpl(fig)
502
507
# If you want to to download an image of the figure as well
503
- plot_mpl(fig, image=True )
508
+ plot_mpl(fig, image='png' )
504
509
```
505
510
"""
506
511
plotly_plot = tools .mpl_to_plotly (mpl_fig , resize , strip_style , verbose )
507
512
return plot (plotly_plot , show_link , link_text , validate , output_type ,
508
513
include_plotlyjs , filename , auto_open ,
509
514
image = image , image_filename = image_filename ,
510
- format = format , _height = _height , _width = _width )
515
+ format = format , image_height = image_height ,
516
+ image_width = image_width )
511
517
512
518
513
519
def iplot_mpl (mpl_fig , resize = False , strip_style = False ,
514
520
verbose = False , show_link = True ,
515
521
link_text = 'Export to plot.ly' , validate = True ,
516
- image = False , image_filename = 'plot_image' , _format = 'png ' ,
517
- _height = 600 , _width = 800 ):
522
+ image = None , image_filename = 'plot_image' ,
523
+ image_height = 600 , image_width = 800 ):
518
524
"""
519
525
Convert a matplotlib figure to a plotly graph and plot inside an IPython
520
526
notebook without connecting to an external server.
@@ -543,14 +549,14 @@ def iplot_mpl(mpl_fig, resize=False, strip_style=False,
543
549
has become outdated with your version of
544
550
graph_reference.json or if you need to include
545
551
extra, unnecessary keys in your figure.
546
- image (default=False) -- If True, the image of the current plot will be
547
- downloaded.
548
- _format (default='png') -- Specifies the format of the image to be
549
- downloaded if `downlowad_image` is True .
552
+ image (default=None |'png' |'jpeg' |'svg' |'webp') -- This parameter sets
553
+ the format of the image to be downloaded, if we choose to download an
554
+ image. This parameter has a default value of None indicating that no
555
+ image should be downloaded .
550
556
image_filename (default='plot_image') -- Sets the name of the file your
551
557
image will be saved to. The extension should not be included.
552
- _height (default=600) -- Specifies the height of the image in `px`.
553
- _width (default=800) -- Specifies the width of the image in `px`.
558
+ image_height (default=600) -- Specifies the height of the image in `px`.
559
+ image_width (default=800) -- Specifies the width of the image in `px`.
554
560
555
561
Example:
556
562
```
@@ -565,13 +571,13 @@ def iplot_mpl(mpl_fig, resize=False, strip_style=False,
565
571
init_notebook_mode()
566
572
iplot_mpl(fig)
567
573
# and if you want to download an image of the figure as well
568
- iplot_mpl(fig, image=True )
574
+ iplot_mpl(fig, image='jpeg' )
569
575
```
570
576
"""
571
577
plotly_plot = tools .mpl_to_plotly (mpl_fig , resize , strip_style , verbose )
572
578
return iplot (plotly_plot , show_link , link_text , validate ,
573
579
image = image , filename = image_filename ,
574
- format = _format , _height = _height , _width = _width )
580
+ image_height = image_height , image_width = image_width )
575
581
576
582
577
583
def enable_mpl_offline (resize = False , strip_style = False ,
0 commit comments