Skip to content

Commit 97ad010

Browse files
Merge branch 'doc-prod'
2 parents f13d299 + b336637 commit 97ad010

File tree

7 files changed

+75
-43
lines changed

7 files changed

+75
-43
lines changed

Diff for: doc/python/aggregations.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ layout = dict(
191191
method = 'restyle',
192192
), dict(
193193
args = ['xbins.size', 'M3'],
194-
label = 'Quater',
194+
label = 'Quarter',
195195
method = 'restyle',
196196
), dict(
197197
args = ['xbins.size', 'M6'],

Diff for: doc/python/builtin-colorscales.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jupyter:
4141
Many Plotly Express functions accept a `color_continuous_scale` argument and many trace
4242
types have a `colorscale` attribute in their schema. Plotly comes with a large number of
4343
built-in continuous color scales, which can be referred to in Python code when setting the above arguments,
44-
either by name in a case-insensitive string e.g. `px.scatter(continuous_color_scale="Viridis"`) or by reference e.g.
44+
either by name in a case-insensitive string e.g. `px.scatter(color_continuous_scale="Viridis"`) or by reference e.g.
4545
`go.Scatter(marker_colorscale=plotly.colors.sequential.Viridis)`. They can also be reversed by adding `_r` at the end
4646
e.g. `"Viridis_r"` or `plotly.colors.sequential.Viridis_r`.
4747

Diff for: doc/python/dumbbell-plots.md

+58-32
Original file line numberDiff line numberDiff line change
@@ -55,47 +55,59 @@ countries = (
5555
.unique()
5656
)
5757

58-
data = {"x": [], "y": [], "colors": [], "years": []}
58+
data = {"line_x": [], "line_y": [], "1952": [], "2002": [], "colors": [], "years": [], "countries": []}
5959

6060
for country in countries:
61-
data["x"].extend(
61+
data["1952"].extend([df.loc[(df.year == 1952) & (df.country == country)]["lifeExp"].values[0]])
62+
data["2002"].extend([df.loc[(df.year == 2002) & (df.country == country)]["lifeExp"].values[0]])
63+
data["line_x"].extend(
6264
[
6365
df.loc[(df.year == 1952) & (df.country == country)]["lifeExp"].values[0],
6466
df.loc[(df.year == 2002) & (df.country == country)]["lifeExp"].values[0],
6567
None,
6668
]
6769
)
68-
data["y"].extend([country, country, None]),
69-
data["colors"].extend(["green", "blue", "brown"]),
70-
data["years"].extend(["1952", "2002", None])
70+
data["line_y"].extend([country, country, None]),
7171

7272
fig = go.Figure(
7373
data=[
7474
go.Scatter(
75-
x=data["x"],
76-
y=data["y"],
75+
x=data["line_x"],
76+
y=data["line_y"],
7777
mode="lines",
78+
showlegend=False,
7879
marker=dict(
79-
color="grey",
80-
),
80+
color="grey"
81+
)
8182
),
8283
go.Scatter(
83-
x=data["x"],
84-
y=data["y"],
85-
mode="markers+text",
84+
x=data["1952"],
85+
y=countries,
86+
mode="markers",
87+
name="1952",
8688
marker=dict(
87-
color=data["colors"],
88-
size=10,
89-
),
90-
hovertemplate="""Country: %{y} <br> Life Expectancy: %{x} <br><extra></extra>""",
89+
color="green",
90+
size=10
91+
)
92+
93+
),
94+
go.Scatter(
95+
x=data["2002"],
96+
y=countries,
97+
mode="markers",
98+
name="2002",
99+
marker=dict(
100+
color="blue",
101+
size=10
102+
)
91103
),
92104
]
93105
)
94106

95107
fig.update_layout(
96108
title="Life Expectancy in Europe: 1952 and 2002",
97109
height=1000,
98-
showlegend=False,
110+
legend_itemclick=False
99111
)
100112

101113
fig.show()
@@ -124,48 +136,62 @@ countries = (
124136
.unique()
125137
)
126138

127-
data = {"x": [], "y": [], "colors": [], "years": []}
139+
data = {"line_x": [], "line_y": [], "1952": [], "2002": [], "colors": [], "years": [], "countries": []}
128140

129141
for country in countries:
130-
data["x"].extend(
142+
data["1952"].extend([df.loc[(df.year == 1952) & (df.country == country)]["lifeExp"].values[0]])
143+
data["2002"].extend([df.loc[(df.year == 2002) & (df.country == country)]["lifeExp"].values[0]])
144+
data["line_x"].extend(
131145
[
132146
df.loc[(df.year == 1952) & (df.country == country)]["lifeExp"].values[0],
133147
df.loc[(df.year == 2002) & (df.country == country)]["lifeExp"].values[0],
134148
None,
135149
]
136150
)
137-
data["y"].extend([country, country, None]),
138-
data["colors"].extend(["silver", "lightskyblue", "white"]),
139-
data["years"].extend(["1952", "2002", None])
151+
data["line_y"].extend([country, country, None]),
140152

141153
fig = go.Figure(
142154
data=[
143155
go.Scatter(
144-
x=data["x"],
145-
y=data["y"],
156+
x=data["line_x"],
157+
y=data["line_y"],
146158
mode="markers+lines",
159+
showlegend=False,
147160
marker=dict(
148-
symbol="arrow", color="black", size=16, angleref="previous", standoff=8
149-
),
161+
symbol="arrow",
162+
color="black",
163+
size=16,
164+
angleref="previous",
165+
standoff=8
166+
)
167+
),
168+
go.Scatter(
169+
x=data["1952"],
170+
y=countries,
171+
name="1952",
172+
mode="markers",
173+
marker=dict(
174+
color="silver",
175+
size=16,
176+
)
150177
),
151178
go.Scatter(
152-
x=data["x"],
153-
y=data["y"],
154-
text=data["years"],
179+
x=data["2002"],
180+
y=countries,
181+
name="2002",
155182
mode="markers",
156183
marker=dict(
157-
color=data["colors"],
184+
color="lightskyblue",
158185
size=16,
159186
),
160-
hovertemplate="""Country: %{y} <br> Life Expectancy: %{x} <br> Year: %{text} <br><extra></extra>""",
161187
),
162188
]
163189
)
164190

165191
fig.update_layout(
166192
title="Life Expectancy in Europe: 1952 and 2002",
167193
height=1000,
168-
showlegend=False,
194+
legend_itemclick=False
169195
)
170196

171197

Diff for: doc/python/histograms.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jupyter:
4040
In statistics, a [histogram](https://en.wikipedia.org/wiki/Histogram) is representation of the distribution of numerical data, where the data are binned and the count for each bin is represented. More generally, in Plotly a histogram is an aggregated bar chart, with several possible aggregation functions (e.g. sum, average, count...) which can be used to visualize data on categorical and date axes as well as linear axes.
4141

4242

43-
Alternatives to violin plots for visualizing distributions include [violin plots](https://plotly.com/python/violin/), [box plots](https://plotly.com/python/box-plots/), [ECDF plots](https://plotly.com/python/ecdf-plots/) and [strip charts](https://plotly.com/python/strip-charts/).
43+
Alternatives to histogram plots for visualizing distributions include [violin plots](https://plotly.com/python/violin/), [box plots](https://plotly.com/python/box-plots/), [ECDF plots](https://plotly.com/python/ecdf-plots/) and [strip charts](https://plotly.com/python/strip-charts/).
4444

4545
> If you're looking instead for bar charts, i.e. representing *raw, unaggregated* data with rectangular
4646
bar, go to the [Bar Chart tutorial](/python/bar-charts/).

Diff for: doc/python/ml-pca.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,16 @@ loadings = pca.components_.T * np.sqrt(pca.explained_variance_)
250250
fig = px.scatter(components, x=0, y=1, color=df['species'])
251251

252252
for i, feature in enumerate(features):
253-
fig.add_shape(
254-
type='line',
255-
x0=0, y0=0,
256-
x1=loadings[i, 0],
257-
y1=loadings[i, 1]
253+
fig.add_annotation(
254+
ax=0, ay=0,
255+
axref="x", ayref="y",
256+
x=loadings[i, 0],
257+
y=loadings[i, 1],
258+
showarrow=True,
259+
arrowsize=2,
260+
arrowhead=2,
261+
xanchor="right",
262+
yanchor="top"
258263
)
259264
fig.add_annotation(
260265
x=loadings[i, 0],
@@ -263,6 +268,7 @@ for i, feature in enumerate(features):
263268
xanchor="center",
264269
yanchor="bottom",
265270
text=feature,
271+
yshift=5,
266272
)
267273
fig.show()
268274
```

Diff for: doc/python/shapes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The differences between these two approaches are that:
5151

5252
### Shape-drawing with Scatter traces
5353

54-
There are two ways to draw filled shapes: scatter traces and [layout.shapes](https://plotly.com/python/reference/layout/shapes/#layout-shapes-items-shape-type) which is mostly useful for the 2d subplots, and defines the shape type to be drawn, and can be rectangle, circle, line, or path (a custom SVG path). You also can use [scatterpolar](https://plotly.com/python/polar-chart/#categorical-polar-chart), scattergeo, [scattermapbox](https://plotly.com/python/filled-area-on-mapbox/#filled-scattermapbox-trace) to draw filled shapes on any kind of subplots. To set an area to be filled with a solid color, you need to define [Scatter.fill="toself"](https://plotly.com/python/reference/scatter/#scatter-fill) that connects the endpoints of the trace into a closed shape. If `mode=line` (default value), then you need to repeat the initial point of a shape at the of the sequence to have a closed shape.
54+
There are two ways to draw filled shapes: scatter traces and [layout.shapes](https://plotly.com/python/reference/layout/shapes/#layout-shapes-items-shape-type) which is mostly useful for the 2d subplots, and defines the shape type to be drawn, and can be rectangle, circle, line, or path (a custom SVG path). You also can use [scatterpolar](https://plotly.com/python/polar-chart/#categorical-polar-chart), scattergeo, [scattermapbox](https://plotly.com/python/filled-area-on-mapbox/#filled-scattermapbox-trace) to draw filled shapes on any kind of subplots. To set an area to be filled with a solid color, you need to define [Scatter.fill="toself"](https://plotly.com/python/reference/scatter/#scatter-fill) that connects the endpoints of the trace into a closed shape. If `mode=line` (default value), then you need to repeat the initial point of a shape at the end of the sequence to have a closed shape.
5555

5656
```python
5757
import plotly.graph_objects as go

Diff for: doc/python/splom.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Specify the columns to be represented with the `dimensions` argument, and set co
5656
import plotly.express as px
5757
df = px.data.iris()
5858
fig = px.scatter_matrix(df,
59-
dimensions=["sepal_width", "sepal_length", "petal_width", "petal_length"],
59+
dimensions=["sepal_length", "sepal_width", "petal_length", "petal_width"],
6060
color="species")
6161
fig.show()
6262
```
@@ -69,7 +69,7 @@ The scatter matrix plot can be configured thanks to the parameters of `px.scatte
6969
import plotly.express as px
7070
df = px.data.iris()
7171
fig = px.scatter_matrix(df,
72-
dimensions=["sepal_width", "sepal_length", "petal_width", "petal_length"],
72+
dimensions=["sepal_length", "sepal_width", "petal_length", "petal_width"],
7373
color="species", symbol="species",
7474
title="Scatter matrix of iris data set",
7575
labels={col:col.replace('_', ' ') for col in df.columns}) # remove underscore

0 commit comments

Comments
 (0)