Skip to content

Remove deprecated attributes from docs #4793

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 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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!
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
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
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
32 changes: 20 additions & 12 deletions doc/python/multiple-axes.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,22 @@ fig.update_layout(
domain=[0.3, 0.7]
),
yaxis=dict(
title="yaxis title",
titlefont=dict(
color="#1f77b4"
title=dict(
text="yaxis title",
font=dict(
color="#1f77b4"
)
),
tickfont=dict(
color="#1f77b4"
)
),
yaxis2=dict(
title="yaxis2 title",
titlefont=dict(
color="#ff7f0e"
title=dict(
text="yaxis2 title",
font=dict(
color="#ff7f0e"
)
),
tickfont=dict(
color="#ff7f0e"
Expand All @@ -214,9 +218,11 @@ fig.update_layout(
position=0.15
),
yaxis3=dict(
title="yaxis3 title",
titlefont=dict(
color="#d62728"
title=dict(
text="yaxis3 title",
font=dict(
color="#d62728"
)
),
tickfont=dict(
color="#d62728"
Expand All @@ -226,9 +232,11 @@ fig.update_layout(
side="right"
),
yaxis4=dict(
title="yaxis4 title",
titlefont=dict(
color="#9467bd"
title=dict(
text="yaxis4 title",
font=dict(
color="#9467bd"
)
),
tickfont=dict(
color="#9467bd"
Expand Down
14 changes: 10 additions & 4 deletions doc/python/network-graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ node_trace = go.Scatter(
size=10,
colorbar=dict(
thickness=15,
title='Node Connections',
title=dict(
text='Node Connections',
side='right'
),
xanchor='left',
titleside='right'
),
line_width=2))

Expand Down Expand Up @@ -128,8 +130,12 @@ node_trace.text = node_text
```python
fig = go.Figure(data=[edge_trace, node_trace],
layout=go.Layout(
title='<br>Network graph made with Python',
titlefont_size=16,
title=dict(
text="<br>Network graph made with Python",
font=dict(
size=16
)
),
showlegend=False,
hovermode='closest',
margin=dict(b=20,l=5,r=5,t=40),
Expand Down
Loading