Skip to content

Commit c75c079

Browse files
Merge branch 'doc-prod' into release_4.9.0
2 parents 950a54a + 9ce2254 commit c75c079

14 files changed

+201
-150
lines changed

Diff for: doc/python/2D-Histogram.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ fig.show()
9696

9797
### 2D Histograms with Graph Objects
9898

99-
To build this kind of plot without using Plotly Express, we can use the `go.Histogram2d` class.
99+
To build this kind of figure using [graph objects](/python/graph-objects/) without using Plotly Express, we can use the `go.Histogram2d` class.
100100

101101

102102
### 2D Histogram of a Bivariate Normal Distribution ###
@@ -236,4 +236,4 @@ fig.show()
236236
```
237237

238238
#### Reference
239-
See https://plotly.com/python/reference/#histogram2d for more information and chart attribute options!
239+
See https://plotly.com/python/reference/#histogram2d for more information and chart attribute options!

Diff for: doc/python/2d-histogram-contour.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fig.show()
9595

9696
### 2D Histograms with Graph Objects
9797

98-
To build this kind of plot without using Plotly Express, we can use the `go.Histogram2d` class.
98+
To build this kind of figure with [graph objects](/python/graph-objects/) without using Plotly Express, we can use the `go.Histogram2d` class.
9999

100100
#### Basic 2D Histogram Contour
101101

@@ -249,4 +249,4 @@ fig.show()
249249
```
250250

251251
#### Reference
252-
See https://plotly.com/python/reference/#histogram2dcontour for more information and chart attribute options!
252+
See https://plotly.com/python/reference/#histogram2dcontour for more information and chart attribute options!

Diff for: doc/python/animations.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jupyter:
2525

2626
#### Animated figures with Plotly Express
2727

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.
2929

3030
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.
3131

@@ -54,12 +54,12 @@ fig.show()
5454
### Current Animation Limitations and Caveats
5555

5656
* 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
5959

6060
#### Animated figures with Graph Objects
6161

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.
6363

6464
#### Frames
6565

Diff for: doc/python/bubble-maps.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jupyter:
3535

3636
#### Base Map Configuration
3737

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.
3939

4040
### Bubble map with Plotly Express
4141

@@ -208,4 +208,4 @@ fig.show()
208208

209209
#### Reference
210210

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!

Diff for: doc/python/choropleth-maps.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Below we show how to create Choropleth Maps using either Plotly Express' `px.cho
3939

4040
#### Base Map Configuration
4141

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.
4343

4444
### Introduction: main parameters for choropleth outline maps
4545

@@ -347,4 +347,4 @@ fig.show()
347347

348348
#### Reference
349349

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!

Diff for: doc/python/colorscales.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ This document explains the following four continuous-color-related concepts:
5252

5353
### Continuous Color with Plotly Express
5454

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.
5656

5757
For example, in the `tips` dataset, the `size` column contains numbers:
5858

@@ -92,7 +92,7 @@ fig.show()
9292

9393
### Color Scales in Plotly Express
9494

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.
9696

9797
Here is an example that creates a scatter plot using Plotly Express, with points colored using the Viridis color scale.
9898

@@ -557,4 +557,4 @@ fig.show()
557557

558558
### Reference
559559

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!

Diff for: doc/python/figure-labels.md

+64-7
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ jupyter:
55
text_representation:
66
extension: .md
77
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
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.7.3
23+
version: 3.7.7
2424
plotly:
2525
description: How to set the global font, title, legend-entries, and axis-titles
2626
in python.
@@ -34,6 +34,62 @@ jupyter:
3434
thumbnail: thumbnail/figure-labels.png
3535
---
3636

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.
44+
45+
```python
46+
import plotly.express as px
47+
48+
df = px.data.iris()
49+
fig = px.scatter(df, x="sepal_length", y="sepal_width", color="species",
50+
title="Automatic Labels Based on Data Frame Column Names")
51+
fig.show()
52+
```
53+
54+
```python
55+
import plotly.express as px
56+
57+
df = px.data.iris()
58+
fig = px.scatter(df, x="sepal_length", y="sepal_width", color="species",
59+
labels={
60+
"sepal_length": "Sepal Length (cm)",
61+
"sepal_width": "Sepal Width (cm)",
62+
"species": "Species of Iris"
63+
},
64+
title="Manually Specified Labels")
65+
fig.show()
66+
```
67+
68+
### Global and Local Font Specification
69+
70+
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.
71+
72+
```python
73+
import plotly.express as px
74+
75+
df = px.data.iris()
76+
fig = px.scatter(df, x="sepal_length", y="sepal_width", color="species",
77+
title="Playing with Fonts")
78+
fig.update_layout(
79+
font_family="Courier New",
80+
font_color="blue",
81+
title_font_family="Times New Roman",
82+
title_font_color="red",
83+
legend_title_font_color="green"
84+
)
85+
fig.update_xaxes(title_font_family="Arial")
86+
fig.show()
87+
```
88+
89+
### Manual Labelling with Graph Objects
90+
91+
When using (graph objects)[/python/graph-objects/] rather than [Plotly Express](/python/plotly-express/), you will need to explicitly label traces and axes:
92+
3793
```python
3894
import plotly.graph_objects as go
3995

@@ -54,12 +110,13 @@ fig.add_trace(go.Scatter(
54110

55111
fig.update_layout(
56112
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",
59116
font=dict(
60117
family="Courier New, monospace",
61118
size=18,
62-
color="#7f7f7f"
119+
color="RebeccaPurple"
63120
)
64121
)
65122

@@ -90,4 +147,4 @@ fig.show()
90147
```
91148

92149
#### Reference
93-
See https://plotly.com/python/reference/#layout for more information!
150+
See https://plotly.com/python/reference/#layout for more information!

Diff for: doc/python/figure-structure.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ At [render-time](/python/renderers/), it is also possible to control certain fig
101101

102102
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`.
103103

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.
105105

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.
107107

108108
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.
109109

@@ -184,8 +184,12 @@ The following trace types are compatible with `carpet` trace subplots via the `c
184184

185185
### Trace Types, Legends and Color Bars
186186

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.
188188

189189
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.
190190

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.
192+
193+
```python
194+
195+
```

0 commit comments

Comments
 (0)