You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/python/creating-and-updating-figures.md
+11-10
Original file line number
Diff line number
Diff line change
@@ -85,13 +85,13 @@ This is a perfectly valid way to use `plotly.py` to build figures. On the other
85
85
86
86
As an alternative to working with Python dictionaries, the `plotly.py` graphing library provides a hierarchy of classes called "graph objects" that may be used to construct figures. Graph objects have several benefits compared to plain Python dictionaries.
87
87
88
-
1.Graph objects provide precise data validation. If you provide an invalid property name or an invalid property value as the key to a graph object, an exception will be raised with a helpful error message describing the problem. This is not the case if you use plain Python dictionaries and lists to build your figures.
88
+
1. Graph objects provide precise data validation. If you provide an invalid property name or an invalid property value as the key to a graph object, an exception will be raised with a helpful error message describing the problem. This is not the case if you use plain Python dictionaries and lists to build your figures.
89
89
90
-
2.Graph objects contain descriptions of each valid property as Python `docstrings`. You can use these `docstrings` in the development environment of your choice to learn about the available properties as an alternative to consulting the online _Full Reference_.
90
+
2. Graph objects contain descriptions of each valid property as Python `docstrings`. You can use these `docstrings` in the development environment of your choice to learn about the available properties as an alternative to consulting the online [Full Reference](/python/reference/).
91
91
92
-
3.Properties of graph objects can be accessed using both dictionary-style key lookup (e.g. `fig["layout"]`) or class-style property access (e.g. `fig.layout`).
92
+
3. Properties of graph objects can be accessed using both dictionary-style key lookup (e.g. `fig["layout"]`) or class-style property access (e.g. `fig.layout`).
93
93
94
-
4.Graph objects support higher-level convenience functions for making updates to already constructed figures, as described below.
94
+
4. Graph objects support higher-level convenience functions for making updates to already constructed figures, as described below.
95
95
96
96
**Graph objects are stored in a hierarchy of modules under the `plotly.graph_objects` package, so make sure to remember to `import plotly.graph_objects as go` when you want to use them.**
97
97
@@ -136,21 +136,22 @@ import plotly.graph_objects as go
136
136
137
137
fig = go.Figure(
138
138
data=[go.Bar(x=[1, 2, 3], y=[1, 3, 2])],
139
-
layout=go.Layout(
140
-
title=go.layout.Title(text="Converting Graph Objects To Dictionaries and JSON")
141
-
)
139
+
layout=go.Layout(height=600, width=800)
142
140
)
143
141
144
-
print("Dictionary Representation of A Graph Object:\n"+str(fig.to_dict()))
142
+
fig.layout.template =None# to slim down the output
145
143
146
-
print("\n\nJSON Representation of A Graph Object:\n"+str(fig.to_json()))
144
+
print("Dictionary Representation of A Graph Object:\n\n"+str(fig.to_dict()))
145
+
print("\n\n")
146
+
print("JSON Representation of A Graph Object:\n\n"+str(fig.to_json()))
147
+
print("\n\n")
147
148
```
148
149
149
150
### Creating Figures
150
151
151
152
This section summarizes several ways to create new graph object figures with the `plotly.py` graphing library.
152
153
153
-
#### Constructor
154
+
#### Graph Objects `Figure`Constructor
154
155
155
156
As demonstrated above, you can build a complete figure by passing trace and layout specifications to the `plotly.graph_objects.Figure` constructor. These trace and layout specifications can be either dictionaries or graph objects.
0 commit comments