Skip to content

Merge changes from doc-prod to master #4816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
642c15a
Remove errroneous comma in SVG path
SeanMcCarren May 25, 2022
c0c1632
Fix for Python "Custom Buttons" doc page
conpierce8 Jun 23, 2022
15cd598
Replace hex colors with nice colors
conpierce8 Jun 23, 2022
4c91abc
made moving-point-on-a-curve faster
Coding-with-Adam Jan 30, 2023
d64871d
Update ml-roc-pr.md
behloolsabir Feb 9, 2023
58fef66
align center annotations in donut pies
yuji96 Apr 5, 2023
803d441
Update box-plots.md
patelvyom Jul 17, 2023
f1e22f2
update jupyterlab support section
LiamConnors May 2, 2024
5a157d8
Add v1hovermode to the list of all the modebar options
JulianWgs Jun 26, 2024
4d3b236
Merge branch 'doc-prod' into jupyterlab-clarification
marthacryan Aug 23, 2024
5096796
Merge branch 'doc-prod' into jupyterlab-clarification
LiamConnors Aug 30, 2024
b81b50c
Merge branch 'doc-prod' into jupyterlab-clarification
LiamConnors Sep 9, 2024
247d2d6
Merge pull request #4767 from plotly/merge-master-to-doc-prod
LiamConnors Sep 12, 2024
7816992
Merge branch 'doc-prod' into jupyterlab-clarification
LiamConnors Sep 13, 2024
2f88c51
Merge pull request #3793 from conpierce8/doc-py-custom-buttons
LiamConnors Sep 13, 2024
cd7fc3f
Merge pull request #4147 from yuji96/master
LiamConnors Sep 13, 2024
3024f98
Merge pull request #4606 from plotly/jupyterlab-clarification
LiamConnors Sep 13, 2024
5710a77
Merge pull request #4063 from behloolsabir/patch-1
LiamConnors Sep 13, 2024
79417f8
Merge pull request #4044 from Coding-with-Adam/patch-1
LiamConnors Sep 13, 2024
fe7833a
Merge pull request #4647 from JulianWgs/patch-2
LiamConnors Sep 13, 2024
df7e2a6
Merge branch 'doc-prod' into patch-1
LiamConnors Sep 18, 2024
c105f45
Merge pull request #4282 from patelvyom/patch-1
LiamConnors Sep 19, 2024
73722a5
Merge pull request #3746 from SeanMcCarren/patch-1
LiamConnors Oct 2, 2024
2f39de8
fixing a bug that causes the hovertext to show %{text} rather than th…
rl-utility-man Oct 5, 2024
9ce66e6
Merge pull request #4781 from rl-utility-man/patch-6
LiamConnors Oct 7, 2024
ddb0f78
remove deprecated attributes
LiamConnors Oct 10, 2024
0094d5a
fix syntax error
LiamConnors Oct 10, 2024
482e8f8
fix syntax error
LiamConnors Oct 10, 2024
827d9dc
fix example
LiamConnors Oct 10, 2024
dbf9d87
Merge pull request #4793 from plotly/remove-deprecated-attributes
LiamConnors Oct 16, 2024
6293f94
Merge branch 'master' into merge-doc-prod-to-master
LiamConnors Oct 22, 2024
527fdee
Merge branch 'master' into merge-doc-prod-to-master
LiamConnors Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 70 additions & 17 deletions doc/python/3d-bubble-charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ jupyter:
text_representation:
extension: .md
format_name: markdown
format_version: '1.1'
jupytext_version: 1.2.3
format_version: '1.3'
jupytext_version: 1.16.4
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
language_info:
Expand All @@ -20,7 +20,7 @@ jupyter:
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.7.3
version: 3.11.10
plotly:
description: How to make 3D Bubble Charts in Python with Plotly. Three examples
of 3D Bubble Charts.
Expand Down Expand Up @@ -113,12 +113,39 @@ fig = go.Figure(data=go.Scatter3d(
)
))

fig.update_layout(width=800, height=800, title = 'Planets!',
scene = dict(xaxis=dict(title='Distance from Sun', titlefont_color='white'),
yaxis=dict(title='Density', titlefont_color='white'),
zaxis=dict(title='Gravity', titlefont_color='white'),
bgcolor = 'rgb(20, 24, 54)'
))
fig.update_layout(
width=800,
height=800,
title="Planets!",
scene=dict(
xaxis=dict(
title=dict(
text="Distance from Sun",
font=dict(
color="white"
)
)
),
yaxis=dict(
title=dict(
text="Density",
font=dict(
color="white"
)
)
),
zaxis=dict(
title=dict(
text="Gravity",
font=dict(
color="white"
)
)
),
bgcolor="rgb(20, 24, 54)"
)
)


fig.show()
```
Expand Down Expand Up @@ -154,16 +181,42 @@ fig = go.Figure(go.Scatter3d(
)
))

fig.update_layout(width=800, height=800, title = 'Planets!',
scene = dict(xaxis=dict(title='Distance from Sun', titlefont_color='white'),
yaxis=dict(title='Density', titlefont_color='white'),
zaxis=dict(title='Gravity', titlefont_color='white'),
bgcolor = 'rgb(20, 24, 54)'
))
fig.update_layout(
width=800,
height=800,
title="Planets!",
scene=dict(
xaxis=dict(
title=dict(
text="Distance from Sun",
font=dict(
color="white"
)
)
),
yaxis=dict(
title=dict(
text="Density",
font=dict(
color="white"
)
)
),
zaxis=dict(
title=dict(
text="Gravity",
font=dict(
color="white"
)
)
),
bgcolor="rgb(20, 24, 54)"
)
)

fig.show()
```

#### Reference

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!
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!
43 changes: 22 additions & 21 deletions doc/python/animations.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ fig.show()

```python
import plotly.graph_objects as go

import numpy as np

# Generate curve data
t = np.linspace(-1, 1, 100)
x = t + t ** 2
Expand All @@ -156,7 +154,7 @@ xm = np.min(x) - 1.5
xM = np.max(x) + 1.5
ym = np.min(y) - 1.5
yM = np.max(y) + 1.5
N = 50
N = 25
s = np.linspace(-1, 1, N)
xx = s + s ** 2
yy = s - s ** 2
Expand All @@ -167,26 +165,29 @@ fig = go.Figure(
data=[go.Scatter(x=x, y=y,
mode="lines",
line=dict(width=2, color="blue")),
go.Scatter(x=x, y=y,
mode="lines",
line=dict(width=2, color="blue"))],
layout=go.Layout(
go.Scatter(x=[xx[0]], y=[yy[0]],
mode="markers",
marker=dict(color="red", size=10))])
fig.update_layout(width=600, height=450,
xaxis=dict(range=[xm, xM], autorange=False, zeroline=False),
yaxis=dict(range=[ym, yM], autorange=False, zeroline=False),
title_text="Kinematic Generation of a Planar Curve", hovermode="closest",
updatemenus=[dict(type="buttons",
buttons=[dict(label="Play",
method="animate",
args=[None])])]),
frames=[go.Frame(
data=[go.Scatter(
x=[xx[k]],
y=[yy[k]],
mode="markers",
marker=dict(color="red", size=10))])

for k in range(N)]
)
title_text="Kinematic Generation of a Planar Curve", title_x=0.5,
updatemenus = [dict(type = "buttons",
buttons = [
dict(
args = [None, {"frame": {"duration": 10, "redraw": False},
"fromcurrent": True, "transition": {"duration": 10}}],
label = "Play",
method = "animate",

)])])

fig.update(frames=[go.Frame(
data=[go.Scatter(
x=[xx[k]],
y=[yy[k]])],
traces=[1]) # fig.data[1] is updated by each frame
for k in range(N)])

fig.show()
```
Expand Down
20 changes: 12 additions & 8 deletions doc/python/bar-charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jupyter:

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

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

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

Expand Down Expand Up @@ -152,7 +152,7 @@ fig.show()

### Aggregating into Single Colored Bars

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

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

Expand Down Expand Up @@ -304,7 +304,7 @@ fig.update_layout(barmode='stack')
fig.show()
```

### Stacked Bar Chart From Aggregating a DataFrame
### Stacked Bar Chart From Aggregating a DataFrame

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.

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


df = df_summarized[["continent",
df = df_summarized[["continent",
"percent of world population",
"percent of world GDP",
]]

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

fig=go.Figure()
for category in df_summarized["continent"].values:
fig.add_trace(go.Bar(
x=df.columns[1:],
# We need to get a pandas series that contains just the values to graph;
# We need to get a pandas series that contains just the values to graph;
# We do so by selecting the right row, selecting the right columns
# and then transposing and using iloc to convert to a series
# Here, we assume that the bar element category variable is in column 0
Expand Down Expand Up @@ -619,8 +619,12 @@ fig.update_layout(
title='US Export of Plastic Scrap',
xaxis_tickfont_size=14,
yaxis=dict(
title='USD (millions)',
titlefont_size=16,
title=dict(
text="USD (millions)",
font=dict(
size=16
)
),
tickfont_size=14,
),
legend=dict(
Expand Down
12 changes: 3 additions & 9 deletions doc/python/box-plots.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,10 @@ import plotly.graph_objects as go

fig = go.Figure()

fig.add_trace(go.Box(y=[
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
], name="Precompiled Quartiles"))

fig.update_traces(q1=[ 1, 2, 3 ], median=[ 4, 5, 6 ],
fig.add_trace(go.Box(q1=[ 1, 2, 3 ], median=[ 4, 5, 6 ],
q3=[ 7, 8, 9 ], lowerfence=[-1, 0, 1],
upperfence=[5, 6, 7], mean=[ 2.2, 2.8, 3.2 ],
sd=[ 0.2, 0.4, 0.6 ], notchspan=[ 0.2, 0.4, 0.6 ] )
upperfence=[7, 8, 9], mean=[ 2.2, 2.8, 3.2 ],
sd=[ 0.2, 0.4, 0.6 ], notchspan=[ 0.2, 0.4, 0.6 ], name="Precompiled Quartiles"))

fig.show()
```
Expand Down
5 changes: 3 additions & 2 deletions doc/python/carpet-contour.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ fig.add_trace(go.Contourcarpet(
colorbar = dict(
y = 0,
yanchor = "bottom",
titleside = "right",
len = 0.75,
title = "Pressure coefficient, c<sub>p</sub>"
title = dict(
text="Pressure coefficient, c<sub>p</sub>",
side="right")
),
contours = dict(
start = -1,
Expand Down
12 changes: 8 additions & 4 deletions doc/python/colorscales.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,10 @@ fig = go.Figure()
fig.add_trace(go.Heatmap(
z=dataset["z"],
colorbar=dict(
title="Surface Heat",
titleside="top",
title=dict(
text="Surface Heat",
side="top",
),
tickmode="array",
tickvals=[2, 25, 50, 75, 100],
labelalias={100: "Hot", 50: "Mild", 2: "Cold"},
Expand Down Expand Up @@ -545,8 +547,10 @@ fig = go.Figure()
fig.add_trace(go.Heatmap(
z=dataset["z"],
colorbar=dict(
title="Surface Heat",
titleside="top",
title=dict(
text="Surface Heat",
side="top",
),
tickmode="array",
tickvals=[2, 50, 100],
ticktext=["Cool", "Mild", "Hot"],
Expand Down
2 changes: 1 addition & 1 deletion doc/python/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ fig.show(config=config)
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:

- **High-level**: `zoom`, `pan`, `select`, `zoomIn`, `zoomOut`, `autoScale`, `resetScale`
- **2D**: `zoom2d`, `pan2d`, `select2d`, `lasso2d`, `zoomIn2d`, `zoomOut2d`, `autoScale2d`, `resetScale2d`
- **2D**: `zoom2d`, `pan2d`, `select2d`, `lasso2d`, `zoomIn2d`, `zoomOut2d`, `autoScale2d`, `resetScale2d`, `v1hovermode`
- **2D Shape Drawing**: `drawline`, `drawopenpath`, `drawclosedpath`, `drawcircle`, `drawrect`, `eraseshape`
- **3D**: `zoom3d`, `pan3d`, `orbitRotation`, `tableRotation`, `handleDrag3d`, `resetCameraDefault3d`, `resetCameraLastSave3d`, `hoverClosest3d`
- **Cartesian**: `hoverClosestCartesian`, `hoverCompareCartesian`
Expand Down
15 changes: 9 additions & 6 deletions doc/python/contour-plots.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,15 @@ fig = go.Figure(data=
[0.625, 1.25, 3.125, 6.25, 10.625],
[0, 0.625, 2.5, 5.625, 10]],
colorbar=dict(
title='Color bar title', # title here
titleside='right',
titlefont=dict(
size=14,
family='Arial, sans-serif')
)))
title=dict(
text='Color bar title', # title here
side='right',
font=dict(
size=14,
family='Arial, sans-serif')
)
),
))

fig.show()
```
Expand Down
Loading