Skip to content

plot method in GraphWidget #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 20, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
provide some examples for widget plottin
  • Loading branch information
chriddyp committed Feb 20, 2015
commit 84867793ec08ceb005eecd17924f492d6131c852
41 changes: 40 additions & 1 deletion plotly/widgets/graph_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,46 @@ def message_handler(widget, ranges):
self._handle_registration('zoom', callback, remove)

def plot(self, figure_or_data, validate=True):
"""Plot figure_or_data in the Plotly graph.
"""Plot figure_or_data in the Plotly graph widget.

Args:
figure_or_data (dict, list, or plotly.graph_obj object):
The standard Plotly graph object that describes Plotly
graphs as used in `plotly.plotly.plot`. See examples
of the figure_or_data in https://plot.ly/python/

Returns: None

Example 1 - Graph a scatter plot:
```
from plotly.graph_objs import Scatter
g = GraphWidget()
g.plot([Scatter(x=[1, 2, 3], y=[10, 15, 13])])
```

Example 2 - Graph a scatter plot with a title:
```
from plotly.graph_objs import Scatter, Figure, Data
fig = Figure(
data = Data([
Scatter(x=[1, 2, 3], y=[20, 15, 13])
]),
layout = Layout(title='Experimental Data')
)

g = GraphWidget()
g.plot(fig)
```

Example 3 - Clear a graph widget
```
from plotly.graph_objs import Scatter, Figure
g = GraphWidget()
g.plot([Scatter(x=[1, 2, 3], y=[10, 15, 13])])

# Now clear it
g.plot({}) # alternatively, g.plot(Figure())
```
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind throwing in a couple extra lines for docs describing the args?

if figure_or_data == {} or figure_or_data == Figure():
validate = False
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy