Skip to content

Commit b64f288

Browse files
authored
Merge pull request #4816 from plotly/merge-doc-prod-to-master
Merge changes from doc-prod to master
2 parents a6da40b + 527fdee commit b64f288

21 files changed

+256
-166
lines changed

Diff for: doc/python/3d-bubble-charts.md

+69-17
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.1'
9-
jupytext_version: 1.2.3
8+
format_version: '1.3'
9+
jupytext_version: 1.16.4
1010
kernelspec:
11-
display_name: Python 3
11+
display_name: Python 3 (ipykernel)
1212
language: python
1313
name: python3
1414
language_info:
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.7.3
23+
version: 3.11.10
2424
plotly:
2525
description: How to make 3D Bubble Charts in Python with Plotly. Three examples
2626
of 3D Bubble Charts.
@@ -113,12 +113,38 @@ fig = go.Figure(data=go.Scatter3d(
113113
)
114114
))
115115

116-
fig.update_layout(width=800, height=800, title = 'Planets!',
117-
scene = dict(xaxis=dict(title='Distance from Sun', title_font_color='white'),
118-
yaxis=dict(title='Density', title_font_color='white'),
119-
zaxis=dict(title='Gravity', title_font_color='white'),
120-
bgcolor = 'rgb(20, 24, 54)'
121-
))
116+
fig.update_layout(
117+
width=800,
118+
height=800,
119+
title="Planets!",
120+
scene=dict(
121+
xaxis=dict(
122+
title=dict(
123+
text="Distance from Sun",
124+
font=dict(
125+
color="white"
126+
)
127+
)
128+
),
129+
yaxis=dict(
130+
title=dict(
131+
text="Density",
132+
font=dict(
133+
color="white"
134+
)
135+
)
136+
),
137+
zaxis=dict(
138+
title=dict(
139+
text="Gravity",
140+
font=dict(
141+
color="white"
142+
)
143+
)
144+
),
145+
bgcolor="rgb(20, 24, 54)"
146+
)
147+
)
122148

123149
fig.show()
124150
```
@@ -154,16 +180,42 @@ fig = go.Figure(go.Scatter3d(
154180
)
155181
))
156182

157-
fig.update_layout(width=800, height=800, title = 'Planets!',
158-
scene = dict(xaxis=dict(title='Distance from Sun', title_font_color='white'),
159-
yaxis=dict(title='Density', title_font_color='white'),
160-
zaxis=dict(title='Gravity', title_font_color='white'),
161-
bgcolor = 'rgb(20, 24, 54)'
162-
))
183+
fig.update_layout(
184+
width=800,
185+
height=800,
186+
title="Planets!",
187+
scene=dict(
188+
xaxis=dict(
189+
title=dict(
190+
text="Distance from Sun",
191+
font=dict(
192+
color="white"
193+
)
194+
)
195+
),
196+
yaxis=dict(
197+
title=dict(
198+
text="Density",
199+
font=dict(
200+
color="white"
201+
)
202+
)
203+
),
204+
zaxis=dict(
205+
title=dict(
206+
text="Gravity",
207+
font=dict(
208+
color="white"
209+
)
210+
)
211+
),
212+
bgcolor="rgb(20, 24, 54)"
213+
)
214+
)
163215

164216
fig.show()
165217
```
166218

167219
#### Reference
168220

169-
See https://plotly.com/python/reference/scatter3d/ and https://plotly.com/python/reference/scatter/#scatter-marker-sizeref <br>for more information and chart attribute options!
221+
See https://plotly.com/python/reference/scatter3d/ and https://plotly.com/python/reference/scatter/#scatter-marker-sizeref <br>for more information and chart attribute options!

Diff for: doc/python/animations.md

+22-21
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ fig.show()
145145

146146
```python
147147
import plotly.graph_objects as go
148-
149148
import numpy as np
150-
151149
# Generate curve data
152150
t = np.linspace(-1, 1, 100)
153151
x = t + t ** 2
@@ -156,7 +154,7 @@ xm = np.min(x) - 1.5
156154
xM = np.max(x) + 1.5
157155
ym = np.min(y) - 1.5
158156
yM = np.max(y) + 1.5
159-
N = 50
157+
N = 25
160158
s = np.linspace(-1, 1, N)
161159
xx = s + s ** 2
162160
yy = s - s ** 2
@@ -167,26 +165,29 @@ fig = go.Figure(
167165
data=[go.Scatter(x=x, y=y,
168166
mode="lines",
169167
line=dict(width=2, color="blue")),
170-
go.Scatter(x=x, y=y,
171-
mode="lines",
172-
line=dict(width=2, color="blue"))],
173-
layout=go.Layout(
168+
go.Scatter(x=[xx[0]], y=[yy[0]],
169+
mode="markers",
170+
marker=dict(color="red", size=10))])
171+
fig.update_layout(width=600, height=450,
174172
xaxis=dict(range=[xm, xM], autorange=False, zeroline=False),
175173
yaxis=dict(range=[ym, yM], autorange=False, zeroline=False),
176-
title_text="Kinematic Generation of a Planar Curve", hovermode="closest",
177-
updatemenus=[dict(type="buttons",
178-
buttons=[dict(label="Play",
179-
method="animate",
180-
args=[None])])]),
181-
frames=[go.Frame(
182-
data=[go.Scatter(
183-
x=[xx[k]],
184-
y=[yy[k]],
185-
mode="markers",
186-
marker=dict(color="red", size=10))])
187-
188-
for k in range(N)]
189-
)
174+
title_text="Kinematic Generation of a Planar Curve", title_x=0.5,
175+
updatemenus = [dict(type = "buttons",
176+
buttons = [
177+
dict(
178+
args = [None, {"frame": {"duration": 10, "redraw": False},
179+
"fromcurrent": True, "transition": {"duration": 10}}],
180+
label = "Play",
181+
method = "animate",
182+
183+
)])])
184+
185+
fig.update(frames=[go.Frame(
186+
data=[go.Scatter(
187+
x=[xx[k]],
188+
y=[yy[k]])],
189+
traces=[1]) # fig.data[1] is updated by each frame
190+
for k in range(N)])
190191

191192
fig.show()
192193
```

Diff for: doc/python/bar-charts.md

+12-9
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jupyter:
3737

3838
[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/).
3939

40-
With `px.bar`, **each row of the DataFrame is represented as a rectangular mark**. To aggregate multiple data points into the same rectangular mark, please refer to the [histogram documentation](/python/histograms).
40+
With `px.bar`, **each row of the DataFrame is represented as a rectangular mark**. To aggregate multiple data points into the same rectangular mark, please refer to the [histogram documentation](/python/histograms).
4141

4242
In the example below, there is only a single row of data per year, so a single bar is displayed per year.
4343

@@ -152,7 +152,7 @@ fig.show()
152152

153153
### Aggregating into Single Colored Bars
154154

155-
As noted above `px.bar()` will result in **one rectangle drawn per row of input**. This can sometimes result in a striped look as in the examples above. To combine these rectangles into one per color per position, you can use `px.histogram()`, which has [its own detailed documentation page](/python/histogram).
155+
As noted above `px.bar()` will result in **one rectangle drawn per row of input**. This can sometimes result in a striped look as in the examples above. To combine these rectangles into one per color per position, you can use `px.histogram()`, which has [its own detailed documentation page](/python/histogram).
156156

157157
> `px.bar` and `px.histogram` are designed to be nearly interchangeable in their call signatures, so as to be able to switch between aggregated and disaggregated bar representations.
158158
@@ -304,7 +304,7 @@ fig.update_layout(barmode='stack')
304304
fig.show()
305305
```
306306

307-
### Stacked Bar Chart From Aggregating a DataFrame
307+
### Stacked Bar Chart From Aggregating a DataFrame
308308

309309
Stacked bar charts are a powerful way to present results summarizing categories generated using the Pandas aggregate commands. `pandas.DataFrame.agg` produces a wide data set format incompatible with `px.bar`. Transposing and updating the indexes to achieve `px.bar` compatibility is a somewhat involved option. Here is one straightforward alternative, which presents the aggregated data as a stacked bar using plotly.graph_objects.
310310

@@ -326,19 +326,19 @@ df_summarized["percent of world population"]=100*df_summarized["pop"]/df_summari
326326
df_summarized["percent of world GDP"]=100*df_summarized["gdp"]/df_summarized["gdp"].sum()
327327

328328

329-
df = df_summarized[["continent",
329+
df = df_summarized[["continent",
330330
"percent of world population",
331331
"percent of world GDP",
332332
]]
333333

334334
# We now have a wide data frame, but it's in the opposite orientation from the one that px is designed to deal with.
335-
# Transposing it and rebuilding the indexes is an option, but iterating through the DF using graph objects is more succinct.
335+
# Transposing it and rebuilding the indexes is an option, but iterating through the DF using graph objects is more succinct.
336336

337337
fig=go.Figure()
338338
for category in df_summarized["continent"].values:
339339
fig.add_trace(go.Bar(
340340
x=df.columns[1:],
341-
# We need to get a pandas series that contains just the values to graph;
341+
# We need to get a pandas series that contains just the values to graph;
342342
# We do so by selecting the right row, selecting the right columns
343343
# and then transposing and using iloc to convert to a series
344344
# Here, we assume that the bar element category variable is in column 0
@@ -619,9 +619,12 @@ fig.update_layout(
619619
title='US Export of Plastic Scrap',
620620
xaxis_tickfont_size=14,
621621
yaxis=dict(
622-
title='USD (millions)',
623-
title_font_size=16,
624-
tickfont_size=14,
622+
title=dict(
623+
text="USD (millions)",
624+
font=dict(
625+
size=16
626+
)
627+
),
625628
),
626629
legend=dict(
627630
x=0,

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

+3-9
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,10 @@ import plotly.graph_objects as go
233233

234234
fig = go.Figure()
235235

236-
fig.add_trace(go.Box(y=[
237-
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ],
238-
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ],
239-
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
240-
], name="Precompiled Quartiles"))
241-
242-
fig.update_traces(q1=[ 1, 2, 3 ], median=[ 4, 5, 6 ],
236+
fig.add_trace(go.Box(q1=[ 1, 2, 3 ], median=[ 4, 5, 6 ],
243237
q3=[ 7, 8, 9 ], lowerfence=[-1, 0, 1],
244-
upperfence=[5, 6, 7], mean=[ 2.2, 2.8, 3.2 ],
245-
sd=[ 0.2, 0.4, 0.6 ], notchspan=[ 0.2, 0.4, 0.6 ] )
238+
upperfence=[7, 8, 9], mean=[ 2.2, 2.8, 3.2 ],
239+
sd=[ 0.2, 0.4, 0.6 ], notchspan=[ 0.2, 0.4, 0.6 ], name="Precompiled Quartiles"))
246240

247241
fig.show()
248242
```

Diff for: doc/python/carpet-contour.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ fig.add_trace(go.Contourcarpet(
159159
colorbar = dict(
160160
y = 0,
161161
yanchor = "bottom",
162-
titleside = "right",
163162
len = 0.75,
164-
title = "Pressure coefficient, c<sub>p</sub>"
163+
title = dict(
164+
text="Pressure coefficient, c<sub>p</sub>",
165+
side="right")
165166
),
166167
contours = dict(
167168
start = -1,

Diff for: doc/python/colorscales.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,10 @@ fig = go.Figure()
321321
fig.add_trace(go.Heatmap(
322322
z=dataset["z"],
323323
colorbar=dict(
324-
title="Surface Heat",
325-
titleside="top",
324+
title=dict(
325+
text="Surface Heat",
326+
side="top",
327+
),
326328
tickmode="array",
327329
tickvals=[2, 25, 50, 75, 100],
328330
labelalias={100: "Hot", 50: "Mild", 2: "Cold"},
@@ -545,8 +547,10 @@ fig = go.Figure()
545547
fig.add_trace(go.Heatmap(
546548
z=dataset["z"],
547549
colorbar=dict(
548-
title="Surface Heat",
549-
titleside="top",
550+
title=dict(
551+
text="Surface Heat",
552+
side="top",
553+
),
550554
tickmode="array",
551555
tickvals=[2, 50, 100],
552556
ticktext=["Cool", "Mild", "Hot"],

Diff for: doc/python/configuration-options.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ fig.show(config=config)
207207
To delete buttons from the modebar, pass an array of strings containing the names of the buttons you want to remove to the `modeBarButtonsToRemove` attribute in the figure's configuration dictionary. Note that different chart types have different default modebars. The following is a list of all the modebar buttons and the chart types they are associated with:
208208

209209
- **High-level**: `zoom`, `pan`, `select`, `zoomIn`, `zoomOut`, `autoScale`, `resetScale`
210-
- **2D**: `zoom2d`, `pan2d`, `select2d`, `lasso2d`, `zoomIn2d`, `zoomOut2d`, `autoScale2d`, `resetScale2d`
210+
- **2D**: `zoom2d`, `pan2d`, `select2d`, `lasso2d`, `zoomIn2d`, `zoomOut2d`, `autoScale2d`, `resetScale2d`, `v1hovermode`
211211
- **2D Shape Drawing**: `drawline`, `drawopenpath`, `drawclosedpath`, `drawcircle`, `drawrect`, `eraseshape`
212212
- **3D**: `zoom3d`, `pan3d`, `orbitRotation`, `tableRotation`, `handleDrag3d`, `resetCameraDefault3d`, `resetCameraLastSave3d`, `hoverClosest3d`
213213
- **Cartesian**: `hoverClosestCartesian`, `hoverCompareCartesian`

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

+9-6
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,15 @@ fig = go.Figure(data=
281281
[0.625, 1.25, 3.125, 6.25, 10.625],
282282
[0, 0.625, 2.5, 5.625, 10]],
283283
colorbar=dict(
284-
title='Color bar title', # title here
285-
titleside='right',
286-
title_font=dict(
287-
size=14,
288-
family='Arial, sans-serif')
289-
)))
284+
title=dict(
285+
text='Color bar title', # title here
286+
side='right',
287+
font=dict(
288+
size=14,
289+
family='Arial, sans-serif')
290+
)
291+
),
292+
))
290293

291294
fig.show()
292295
```

0 commit comments

Comments
 (0)