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/animations.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ jupyter:
25
25
26
26
#### Animated figures with Plotly Express
27
27
28
-
Several Plotly Express functions support the creation of animated figures through the `animation_frame` and `animation_group` arguments.
28
+
Several [Plotly Express](/python/plotly-express/) functions support the creation of animated figures through the `animation_frame` and `animation_group` arguments.
29
29
30
30
Here is an example of an animated scatter plot creating using Plotly Express. Note that you should always fix the `x_range` and `y_range` to ensure that your data remains visible throughout the animation.
31
31
@@ -54,12 +54,12 @@ fig.show()
54
54
### Current Animation Limitations and Caveats
55
55
56
56
* Animations are designed to work well when each row of input is present across all animation frames, and when categorical values mapped to symbol, color and facet are constant across frames. Animations *may be misleading or inconsistent* if these constraints are not met.
57
-
* Although Plotly Express supports animation for many chart and map types, smooth inter-frame transitions are today only possible for scatter and bar
58
-
* Plotly Express will not automatically compute the union of all x/y/color ranges, so these must be specified manually to avoid scale jumps across frames
57
+
* Although Plotly Express supports animation for many chart and map types, smooth inter-frame transitions are today *only* possible for `scatter` and `bar`
58
+
* Plotly Express will *not* automatically compute the union of all x/y/color ranges, so these must be specified manually to avoid scale jumps across frames
59
59
60
60
#### Animated figures with Graph Objects
61
61
62
-
The remainder of this section describes the low-level API for constructing animated figures manually.
62
+
The remainder of this section describes the low-level [graph objects](/python/graph-objects/)API for constructing animated figures manually.
Copy file name to clipboardExpand all lines: doc/python/bubble-maps.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ jupyter:
35
35
36
36
#### Base Map Configuration
37
37
38
-
Plotly figures made with `px.scatter_geo`, `px.line_geo` or `px.choropleth` functions or containing `go.Choropleth` or `go.Scattergeo` graph objects have a `go.layout.Geo` object which can be used to [control the appearance of the base map](/python/map-configuration/) onto which data is plotted.
38
+
Plotly figures made with [Plotly Express](/python/plotly-express/)`px.scatter_geo`, `px.line_geo` or `px.choropleth` functions or containing `go.Choropleth` or `go.Scattergeo`[graph objects](/python/graph-objects/) have a `go.layout.Geo` object which can be used to [control the appearance of the base map](/python/map-configuration/) onto which data is plotted.
39
39
40
40
### Bubble map with Plotly Express
41
41
@@ -208,4 +208,4 @@ fig.show()
208
208
209
209
#### Reference
210
210
211
-
See https://plotly.com/python/reference/#choropleth and https://plotly.com/python/reference/#scattergeo for more information and chart attribute options!
211
+
See https://plotly.com/python/reference/#choropleth and https://plotly.com/python/reference/#scattergeo for more information and chart attribute options!
Copy file name to clipboardExpand all lines: doc/python/choropleth-maps.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ Below we show how to create Choropleth Maps using either Plotly Express' `px.cho
39
39
40
40
#### Base Map Configuration
41
41
42
-
Plotly figures made with `px.scatter_geo`, `px.line_geo` or `px.choropleth` functions or containing `go.Choropleth` or `go.Scattergeo` graph objects have a `go.layout.Geo` object which can be used to [control the appearance of the base map](/python/map-configuration/) onto which data is plotted.
42
+
Plotly figures made with [Plotly Express](/python/plotly-express/)`px.scatter_geo`, `px.line_geo` or `px.choropleth` functions or containing `go.Choropleth` or `go.Scattergeo`[graph objects](/python/graph-objects/) have a `go.layout.Geo` object which can be used to [control the appearance of the base map](/python/map-configuration/) onto which data is plotted.
43
43
44
44
### Introduction: main parameters for choropleth outline maps
45
45
@@ -347,4 +347,4 @@ fig.show()
347
347
348
348
#### Reference
349
349
350
-
See https://plotly.com/python/reference/#choropleth for more information and chart attribute options!
350
+
See https://plotly.com/python/reference/#choropleth for more information and chart attribute options!
Copy file name to clipboardExpand all lines: doc/python/colorscales.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,7 @@ This document explains the following four continuous-color-related concepts:
52
52
53
53
### Continuous Color with Plotly Express
54
54
55
-
Most Plotly Express functions accept a `color` argument which automatically assigns data values to continuous color **if the data is numeric**. If the data contains strings, the color will automatically be considered [discrete (also known as categorical or qualitative)](/python/discrete-color/). This means that numeric strings must be parsed to be used for continuous color, and conversely, numbers used as category codes must be converted to strings.
55
+
Most [Plotly Express](/python/plotly-express/) functions accept a `color` argument which automatically assigns data values to continuous color **if the data is numeric**. If the data contains strings, the color will automatically be considered [discrete (also known as categorical or qualitative)](/python/discrete-color/). This means that numeric strings must be parsed to be used for continuous color, and conversely, numbers used as category codes must be converted to strings.
56
56
57
57
For example, in the `tips` dataset, the `size` column contains numbers:
58
58
@@ -92,7 +92,7 @@ fig.show()
92
92
93
93
### Color Scales in Plotly Express
94
94
95
-
By default, Plotly Express will use the color scale from the active [template](/python/templates/)'s `layout.colorscales.sequential` attribute, and the default active template is `plotly` which uses the `Plasma` color scale. You can choose any of the [built-in color scales](/python/builtin-colorscales/), however, or define your own.
95
+
By default, [Plotly Express](/python/plotly-express/) will use the color scale from the active [template](/python/templates/)'s `layout.colorscales.sequential` attribute, and the default active template is `plotly` which uses the `Plasma` color scale. You can choose any of the [built-in color scales](/python/builtin-colorscales/), however, or define your own.
96
96
97
97
Here is an example that creates a scatter plot using Plotly Express, with points colored using the Viridis color scale.
98
98
@@ -557,4 +557,4 @@ fig.show()
557
557
558
558
### Reference
559
559
560
-
See https://plotly.com/python/reference/ for more information and chart attribute options!
560
+
See https://plotly.com/python/reference/ for more information and chart attribute options!
Copy file name to clipboardExpand all lines: doc/python/figure-labels.md
+64-7
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,8 @@ jupyter:
5
5
text_representation:
6
6
extension: .md
7
7
format_name: markdown
8
-
format_version: '1.1'
9
-
jupytext_version: 1.2.1
8
+
format_version: '1.2'
9
+
jupytext_version: 1.4.2
10
10
kernelspec:
11
11
display_name: Python 3
12
12
language: python
@@ -20,7 +20,7 @@ jupyter:
20
20
name: python
21
21
nbconvert_exporter: python
22
22
pygments_lexer: ipython3
23
-
version: 3.7.3
23
+
version: 3.7.7
24
24
plotly:
25
25
description: How to set the global font, title, legend-entries, and axis-titles
26
26
in python.
@@ -34,6 +34,62 @@ jupyter:
34
34
thumbnail: thumbnail/figure-labels.png
35
35
---
36
36
37
+
### Automatic Labelling with Plotly Express
38
+
39
+
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on a variety of types of data](/python/px-arguments/) and produces [easy-to-style figures](/python/styling-plotly-express/).
40
+
41
+
When using Plotly Express, your axes and legend are automatically labelled, and it's easy to override the automation for a customized figure using the `labels` keyword argument. The title of your figure is up to you though!
42
+
43
+
Here's a figure with automatic labels and then the same figure with overridden labels. Note the fact that when overriding labels, the axes, legend title *and hover labels* reflect the specified labels automatically.
You can set the figure-wide font with the `layout.font` attribute, which will apply to all titles and tick labels, but this can be overridden for specific plot items like individual axes and legend titles etc. In the following figure, we set the figure-wide font to Courier New in blue, and then override this for certain parts of the figure.
When using (graph objects)[/python/graph-objects/] rather than [Plotly Express](/python/plotly-express/), you will need to explicitly label traces and axes:
92
+
37
93
```python
38
94
import plotly.graph_objects as go
39
95
@@ -54,12 +110,13 @@ fig.add_trace(go.Scatter(
54
110
55
111
fig.update_layout(
56
112
title="Plot Title",
57
-
xaxis_title="x Axis Title",
58
-
yaxis_title="y Axis Title",
113
+
xaxis_title="X Axis Title",
114
+
yaxis_title="X Axis Title",
115
+
legend_title="Legend Title",
59
116
font=dict(
60
117
family="Courier New, monospace",
61
118
size=18,
62
-
color="#7f7f7f"
119
+
color="RebeccaPurple"
63
120
)
64
121
)
65
122
@@ -90,4 +147,4 @@ fig.show()
90
147
```
91
148
92
149
#### Reference
93
-
See https://plotly.com/python/reference/#layout for more information!
150
+
See https://plotly.com/python/reference/#layout for more information!
Copy file name to clipboardExpand all lines: doc/python/figure-structure.md
+8-4
Original file line number
Diff line number
Diff line change
@@ -101,9 +101,9 @@ At [render-time](/python/renderers/), it is also possible to control certain fig
101
101
102
102
Various figure components configured within the layout of the figure support positioning attributes named `x` or `y`, whose values may be specified in "paper coordinates" (sometimes referred to as "plot fractions" or "normalized coordinates"). Examples include `layout.xaxis.domain` or `layout.legend.x` or `layout.annotation[].x`.
103
103
104
-
Positioning in paper coordinates is not done in absolute pixel terms, but rather in terms relative to a coordinate system defined with an origin `(0,0)` at `(layout.margin.l, layout.margin.b)` and a point `(1,1)` at `(layout.width-layout.margin.r, layout.height-layout.margin.t)`. Values less than 0 or greater than 1 are permitted, and refer to areas within the plot margins.
104
+
Positioning in paper coordinates is *not* done in absolute pixel terms, but rather in terms relative to a coordinate system defined with an origin `(0,0)` at `(layout.margin.l, layout.margin.b)` and a point `(1,1)` at `(layout.width-layout.margin.r, layout.height-layout.margin.t)` (note: `layout.margin` values are pixel values, as are `layout.width` and `layout.height`). Paper coordinate values less than 0 or greater than 1 are permitted, and refer to areas within the plot margins.
105
105
106
-
Note that the contents of the `layout.margin` attribute are by default computed based on the position and dimensions of certain items like the title or legend, and may be made dependent on the position and dimensions of tick labels as well when setting the `layout.xaxis.automargin` attribute to `True`. This has the effect of automatically increasing the margin values and therefore shrinking the physical area defined between the `(0,0)` and `(1,1)` points. Positioning certain items at paper coordinates less than 0 or greater than 1 will also trigger this behavior.
106
+
Note that the contents of the `layout.margin` attribute are by default computed based on the position and dimensions of certain items like the title or legend, and may be made dependent on the position and dimensions of tick labels as well when setting the `layout.xaxis.automargin` attribute to `True`. This has the effect of automatically increasing the margin values and therefore shrinking the physical area defined between the `(0,0)` and `(1,1)` points. Positioning certain items at paper coordinates less than 0 or greater than 1 will also trigger this behavior. The `layout.width` and `layout.height`, however, are taken as givens, so a figure will never grow or shrink based on its contents.
107
107
108
108
The figure title may be positioned using "container coordinates" which have `(0,0)` and `(1,1)` anchored at the bottom-left and top-right of the figure, respectively, and therefore are independent of the values of layout.margin.
109
109
@@ -184,8 +184,12 @@ The following trace types are compatible with `carpet` trace subplots via the `c
184
184
185
185
### Trace Types, Legends and Color Bars
186
186
187
-
Traces of most types can be optionally associated with a single legend item in the [legend](/python/legend/), which can be shown via the `showlegend` attribute. Traces which are their own subplots (see above) do not support this, with the exception of traces of type `pie` and `funnelarea` for which every distinct color represented in the trace gets a separate legend item. Users may show or hide traces by clicking or double-clicking on their associated legend item. Traces that support legend items also support the `legendgroup` attribute, and all traces with the same legend group are treated the same way during click/double-click interactions.
187
+
Traces of most types can be optionally associated with a single legend item in the [legend](/python/legend/). Whether or not a given trace appears in the legend is controlled via the `showlegend` attribute. Traces which are their own subplots (see above) do not support this, with the exception of traces of type `pie` and `funnelarea` for which every distinct color represented in the trace gets a separate legend item. Users may show or hide traces by clicking or double-clicking on their associated legend item. Traces that support legend items also support the `legendgroup` attribute, and all traces with the same legend group are treated the same way during click/double-click interactions.
188
188
189
189
The fact that legend items are linked to traces means that when using [discrete color](/python/discrete-color/), a figure must have one trace per color in order to get a meaningful legend. [Plotly Express has robust support for discrete color](/python/discrete-color/) to make this easy.
190
190
191
-
Traces which support [continuous color](/python/colorscales/) can also be associated with color axes in the layout via the `coloraxis` attribute. Multiple traces can be linked to the same color axis. Color axes have a legend-like component called color bars. Alternatively, color axes can be configured within the trace itself.
191
+
Traces which support [continuous color](/python/colorscales/) can also be associated with color axes in the layout via the `coloraxis` attribute. Multiple traces can be linked to the same color axis. Color axes have a legend-like component called color bars. Alternatively, color axes can be configured within the trace itself.
0 commit comments