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/annotated-heatmap.md
+2-5
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ jupyter:
36
36
37
37
#### Simple Annotated Heatmap
38
38
39
-
For more examples with Heatmaps, see [this page](/python/heatmaps/).
39
+
This page details the use of a [figure factory](/python/figure-factories/). For more examples with Heatmaps, see [this page](/python/heatmaps/).
40
40
41
41
```python
42
42
import plotly.figure_factory as ff
@@ -202,8 +202,5 @@ fig.show()
202
202
```
203
203
204
204
#### Reference
205
-
For more info on Plotly heatmaps, see: https://plotly.com/python/reference/#heatmap.<br> For more info on using colorscales with Plotly see: https://plotly.com/python/heatmap-and-contour-colorscales/ <br>For more info on annotated_heatmaps, see:
206
205
207
-
```python
208
-
help(ff.create_annotated_heatmap)
209
-
```
206
+
For more info on Plotly heatmaps, see: https://plotly.com/python/reference/#heatmap.<br> For more info on using colorscales with Plotly see: https://plotly.com/python/heatmap-and-contour-colorscales/ <br>For more info on `ff.create_annotated_heatmap()`, see the [full function reference](https://plotly.com/python-api-reference/generated/plotly.figure_factory.create_annotated_heatmap.html#plotly.figure_factory.create_annotated_heatmap)
Copy file name to clipboardExpand all lines: doc/python/county-choropleth.md
+3-6
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ jupyter:
37
37
### Deprecation warning
38
38
39
39
40
-
This page describes a legacy "figure factory" method for creating map-like figures using [self-filled scatter traces](/python/shapes). **This is no longer the recommended way to make county-level choropleth maps**, instead we recommend using a [GeoJSON-based approach to making outline choropleth maps](/python/choropleth-maps/) or the alternative [Mapbox tile-based choropleth maps](/python/mapbox-county-choropleth).
40
+
This page describes a [legacy "figure factory" method](/python/figure-factories/) for creating map-like figures using [self-filled scatter traces](/python/shapes). **This is no longer the recommended way to make county-level choropleth maps**, instead we recommend using a [GeoJSON-based approach to making outline choropleth maps](/python/choropleth-maps/) or the alternative [Mapbox tile-based choropleth maps](/python/mapbox-county-choropleth).
41
41
42
42
43
43
#### Required Packages
@@ -275,9 +275,6 @@ fig.show()
275
275
276
276
Also see Mapbox county choropleths made in Python: [https://plotly.com/python/mapbox-county-choropleth/](https://plotly.com/python/mapbox-county-choropleth/)
277
277
278
+
### Reference
278
279
279
-
#### Reference
280
-
281
-
```python
282
-
help(ff.create_choropleth)
283
-
```
280
+
For more info on `ff.create_choropleth()`, see the [full function reference](https://plotly.com/python-api-reference/generated/plotly.figure_factory.create_choropleth.html)
Copy file name to clipboardExpand all lines: doc/python/creating-and-updating-figures.md
+41-38
Original file line number
Diff line number
Diff line change
@@ -39,9 +39,9 @@ jupyter:
39
39
40
40
### Representing Figures
41
41
42
-
The goal of the plotly.py package is to provide a pleasant Python interface for creating figure specifications which are displayed by the [plotly.js](https://plot.ly/javascript) JavaScript graphing library.
42
+
The goal of the plotly.py package is to provide a pleasant Python interface for creating figure specifications which are displayed by the [plotly.js](https://plot.ly/javascript) JavaScript graphing library.
43
43
44
-
In the context of the plotly.js library, a figure is specified by a declarative [JSON](https://www.json.org/json-en.html) data structure.
44
+
In the context of the plotly.js library, a figure is specified by a declarative [JSON](https://www.json.org/json-en.html) data structure.
45
45
46
46
Therefore, you should always keep in mind as you are creating and updating figures using the plotly.py package that its ultimate goal is to help users produce Python [dictionaries](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) that can be automatically [serialized](https://en.wikipedia.org/wiki/Serialization) into the JSON data structure that the plotly.js graphing library understands.
47
47
@@ -63,37 +63,37 @@ import plotly.io as pio
63
63
pio.show(fig)
64
64
```
65
65
66
-
Let's take a closer look at structure of the `fig` dictionary in order to better understand how `plotly.py` figures are built.
66
+
Let's take a closer look at structure of the `fig` dictionary in order to better understand how `plotly.py` figures are built.
67
67
68
68
##### The `"data"` Key
69
69
70
70
The `"data"` key stores the value of list which describes the trace or traces which make up a figure. It is still a list even if the figure only contains one trace, as in the example above.
71
71
72
72
Each trace in the list stored by the `"data"` key is itself defined by a dictionary. The type of the trace (`"bar"`, `"scatter"`, `"contour"`, etc...) is specified with a `"type"` key, and the rest of the keys in a trace specification dictionary (`x`, `y`, etc...) are used to define the properties specific to the trace of that type.
73
73
74
-
##### The `"layout"` Key
74
+
##### The `"layout"` Key
75
75
76
76
The`"layout"` key stores a dictionary that specifies properties related to customizing how the figure looks, such as its title, typography, margins, axes, annotations, shapes, legend and more. In contrast to trace configuration options, which apply only to individual traces, layout configuration options apply to the figure as a whole.
77
77
78
78
The [_Full Reference_](https://plot.ly/python/reference/) page contains descriptions of all of the supported trace and layout attributes and configuration options.
79
79
80
-
If working from the _Full Reference_ to build figures as Python dictionaries and lists suites your needs, go for it!
80
+
If working from the _Full Reference_ to build figures as Python dictionaries and lists suites your needs, go for it!
81
81
82
82
This is a perfectly valid way to use `plotly.py` to build figures. On the other hand, if you would like to use an API that offers you a bit more assistance in the figure creation process, read on to learn about `graph objects`.
83
83
84
84
#### Figures as Graph Objects
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
-
**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.**
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
98
98
Below you can find an example of one way that the figure in the example above could be specified using a graph object instead of a dictionary.
99
99
@@ -136,23 +136,24 @@ 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
-
This section summarizes several ways to create new graph object figures with the `plotly.py` graphing library.
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
-
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.
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.
156
157
157
158
In the following example, the traces are specified using graph objects and the layout is specified as a dictionary.
158
159
@@ -185,7 +186,7 @@ fig.show()
185
186
186
187
#### Figure Factories
187
188
188
-
Figure factories (included in `plotly.py` in the `plotly.figure_factory` module) are functions that produce graph object figures, often to satisfy the needs of specialized domains. Here's an example of using the `create_quiver()` figure factory to construct a graph object figure that displays a 2D quiver plot.
189
+
[Figure factories](/python/figure-factories) (included in `plotly.py` in the `plotly.figure_factory` module) are functions that produce graph object figures, often to satisfy the needs of specialized domains. Here's an example of using the `create_quiver()` figure factory to construct a graph object figure that displays a 2D quiver plot.
title="Adding Traces To Subplots Witin A Plotly Express Figure")
281
282
282
283
reference_line = go.Scatter(x=[2, 4],
@@ -294,7 +295,7 @@ fig.show()
294
295
295
296
#### Add Trace Convenience Methods
296
297
297
-
As an alternative to the `add_trace()` method, graph object figures have a family of methods of the form `add_{trace}` (where `{trace}` is the name of a trace type) for constructing and adding traces of each trace type.
298
+
As an alternative to the `add_trace()` method, graph object figures have a family of methods of the form `add_{trace}` (where `{trace}` is the name of a trace type) for constructing and adding traces of each trace type.
298
299
299
300
Here is the previous subplot example, adapted to add the scatter trace using `fig.add_scatter()` and to add the bar trace using `fig.add_bar()`.
300
301
@@ -311,11 +312,11 @@ fig.show()
311
312
312
313
#### Magic Underscore Notation
313
314
314
-
To make it easier to work with nested properties, graph object constructors and many graph object methods support magic underscore notation.
315
+
To make it easier to work with nested properties, graph object constructors and many graph object methods support magic underscore notation.
315
316
316
317
This allows you to reference nested properties by joining together multiple nested property names with underscores.
317
318
318
-
For example, specifying the figure title in the figure constructor _without_ magic underscore notation requires setting the `layout` argument to `dict(title=dict(text="A Chart"))`.
319
+
For example, specifying the figure title in the figure constructor _without_ magic underscore notation requires setting the `layout` argument to `dict(title=dict(text="A Chart"))`.
319
320
320
321
Similarly, setting the line color of a scatter trace requires setting the `marker` property to `dict(color="crimson")`.
321
322
@@ -349,7 +350,7 @@ Magic underscore notation is supported throughout the graph objects API, and it
349
350
350
351
#### Updating Figure Layouts
351
352
352
-
Graph object figures support an `update_layout()` method that may be used to update multiple nested properties of a figure's layout.
353
+
Graph object figures support an `update_layout()` method that may be used to update multiple nested properties of a figure's layout.
353
354
354
355
Here is an example of updating the text and font size of a figure's title using `update_layout()`.
facet_col="species", title="Using update_xaxes() With A Plotly Express Figure")
605
606
606
607
fig.update_xaxes(showgrid=False)
@@ -613,28 +614,30 @@ There are also `for_each_xaxis()` and `for_each_yaxis()` methods that are analog
613
614
### Other Update Methods
614
615
615
616
Figures created with the plotly.py graphing library also support:
616
-
- the `update_layout_images()` method in order to [update background layout images](/python/images/),
617
-
- `update_annotations()` in order to [update annotations](/python/text-and-annotations/#multiple-annotations),
618
-
- and `update-shapes()` in order to [update shapes](/python/shapes/).
617
+
618
+
- the `update_layout_images()` method in order to [update background layout images](/python/images/),
619
+
-`update_annotations()` in order to [update annotations](/python/text-and-annotations/#multiple-annotations),
620
+
- and `update_shapes()` in order to [update shapes](/python/shapes/).
619
621
620
622
#### Chaining Figure Operations
621
623
622
624
All of the figure update operations described above are methods that return a reference to the figure being modified. This makes it possible the chain multiple figure modification operations together into a single expression.
623
625
624
626
Here is an example of a chained expression that creates:
625
-
- a faceted scatter plot with OLS trend lines using Plotly Express,
626
-
- sets the title font size using `update_layout()`,
627
-
- disables vertical grid lines using `update_xaxes()`,
628
-
- updates the width and dash pattern of the trend lines using `update_traces()`,
629
-
- and then displays the figure using `show()`.
627
+
628
+
- a faceted scatter plot with OLS trend lines using Plotly Express,
629
+
- sets the title font size using `update_layout()`,
630
+
- disables vertical grid lines using `update_xaxes()`,
631
+
- updates the width and dash pattern of the trend lines using `update_traces()`,
Copy file name to clipboardExpand all lines: doc/python/dendrogram.md
+2-4
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ jupyter:
35
35
36
36
#### Basic Dendrogram
37
37
38
-
A [dendrogram](https://en.wikipedia.org/wiki/Dendrogram) is a diagram representing a tree. The figure factory `create_dendrogram` performs [hierachical clustering](https://en.wikipedia.org/wiki/Hierarchical_clustering) on data and represents the resulting tree. Values on the tree depth axis correspond to distances between clusters.
38
+
A [dendrogram](https://en.wikipedia.org/wiki/Dendrogram) is a diagram representing a tree. The [figure factory](/python/figure-factories/) called`create_dendrogram` performs [hierachical clustering](https://en.wikipedia.org/wiki/Hierarchical_clustering) on data and represents the resulting tree. Values on the tree depth axis correspond to distances between clusters.
39
39
40
40
Dendrogram plots are commonly used in computational biology to show the clustering of genes or samples, sometimes in the margin of heatmaps.
41
41
@@ -178,6 +178,4 @@ fig.show()
178
178
179
179
### Reference
180
180
181
-
```python
182
-
help(ff.create_dendrogram)
183
-
```
181
+
For more info on `ff.create_dendrogram()`, see the [full function reference](https://plotly.com/python-api-reference/generated/plotly.figure_factory.create_dendrogram.html)
0 commit comments