Skip to content

Commit 59e0ef6

Browse files
committed
docstrings
1 parent e59f6ad commit 59e0ef6

File tree

1 file changed

+55
-7
lines changed

1 file changed

+55
-7
lines changed

plotly/plotly/plotly.py

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,25 @@ class image:
546546
"""
547547
@staticmethod
548548
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`.
551550
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+
```
553568
554569
"""
555570
# 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):
625640
@classmethod
626641
def ishow(cls, figure_or_data, format='png', width=None, height=None,
627642
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`
630644
in an IPython Notebook.
631645
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)
632662
"""
633663
if format == 'pdf':
634664
raise exceptions.PlotlyError(
@@ -647,13 +677,31 @@ def ishow(cls, figure_or_data, format='png', width=None, height=None,
647677
@classmethod
648678
def save_as(cls, figure_or_data, filename, format=None, width=None,
649679
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`.
652682
653683
Valid image formats are 'png', 'svg', 'jpeg', and 'pdf'.
654684
The format is taken as the extension of the filename or as the
655685
supplied format.
656686
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+
```
657705
"""
658706
# todo: format shadows built-in name
659707
(base, ext) = os.path.splitext(filename)

0 commit comments

Comments
 (0)