@@ -546,10 +546,25 @@ class image:
546
546
"""
547
547
@staticmethod
548
548
def get (figure_or_data , format = 'png' , width = None , height = None , scale = None ):
549
- """
550
- Return a static image of the plot described by `figure`.
549
+ """Return a static image of the plot described by `figure_or_data`.
551
550
552
- Valid formats: 'png', 'svg', 'jpeg', 'pdf'
551
+ positional arguments:
552
+ - figure_or_data: The figure dict-like or data list-like object that
553
+ describes a plotly figure.
554
+ Same argument used in `py.plot`, `py.iplot`,
555
+ see https://plot.ly/python for examples
556
+ - format: 'png', 'svg', 'jpeg', 'pdf'
557
+ - width: output width
558
+ - height: output height
559
+ - scale: Increase the resolution of the image by `scale` amount (e.g. `3`)
560
+ Only valid for PNG and JPEG images.
561
+
562
+ example:
563
+ ```
564
+ import plotly.plotly as py
565
+ fig = {'data': [{'x': [1, 2, 3], 'y': [3, 1, 5], 'type': 'bar'}]}
566
+ py.image.get(fig, 'png', scale=3)
567
+ ```
553
568
554
569
"""
555
570
# TODO: format is a built-in name... we shouldn't really use it
@@ -625,10 +640,25 @@ def get(figure_or_data, format='png', width=None, height=None, scale=None):
625
640
@classmethod
626
641
def ishow (cls , figure_or_data , format = 'png' , width = None , height = None ,
627
642
scale = None ):
628
- """
629
- Display a static image of the plot described by `figure`
643
+ """Display a static image of the plot described by `figure_or_data`
630
644
in an IPython Notebook.
631
645
646
+ positional arguments:
647
+ - figure_or_data: The figure dict-like or data list-like object that
648
+ describes a plotly figure.
649
+ Same argument used in `py.plot`, `py.iplot`,
650
+ see https://plot.ly/python for examples
651
+ - format: 'png', 'svg', 'jpeg', 'pdf'
652
+ - width: output width
653
+ - height: output height
654
+ - scale: Increase the resolution of the image by `scale` amount
655
+ Only valid for PNG and JPEG images.
656
+
657
+ example:
658
+ ```
659
+ import plotly.plotly as py
660
+ fig = {'data': [{'x': [1, 2, 3], 'y': [3, 1, 5], 'type': 'bar'}]}
661
+ py.image.ishow(fig, 'png', scale=3)
632
662
"""
633
663
if format == 'pdf' :
634
664
raise exceptions .PlotlyError (
@@ -647,13 +677,31 @@ def ishow(cls, figure_or_data, format='png', width=None, height=None,
647
677
@classmethod
648
678
def save_as (cls , figure_or_data , filename , format = None , width = None ,
649
679
height = None , scale = None ):
650
- """
651
- Save a image of the plot described by `figure` locally as `filename`.
680
+ """Save a image of the plot described by `figure_or_data` locally as
681
+ `filename`.
652
682
653
683
Valid image formats are 'png', 'svg', 'jpeg', and 'pdf'.
654
684
The format is taken as the extension of the filename or as the
655
685
supplied format.
656
686
687
+ positional arguments:
688
+ - figure_or_data: The figure dict-like or data list-like object that
689
+ describes a plotly figure.
690
+ Same argument used in `py.plot`, `py.iplot`,
691
+ see https://plot.ly/python for examples
692
+ - filename: The filepath to save the image to
693
+ - format: 'png', 'svg', 'jpeg', 'pdf'
694
+ - width: output width
695
+ - height: output height
696
+ - scale: Increase the resolution of the image by `scale` amount
697
+ Only valid for PNG and JPEG images.
698
+
699
+ example:
700
+ ```
701
+ import plotly.plotly as py
702
+ fig = {'data': [{'x': [1, 2, 3], 'y': [3, 1, 5], 'type': 'bar'}]}
703
+ py.image.save_as(fig, 'my_image.png', scale=3)
704
+ ```
657
705
"""
658
706
# todo: format shadows built-in name
659
707
(base , ext ) = os .path .splitext (filename )
0 commit comments