Skip to content
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

Update docs dependencies and Python version #4596

Merged
merged 17 commits into from
May 13, 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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ jobs:
docker:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, for example, `3.9-browsers`
- image: cimg/python:3.9-browsers
- image: cimg/python:3.10-browsers

steps:
- add_ssh_keys:
Expand Down
6 changes: 3 additions & 3 deletions binder/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ jupytext
plotly==5.22.0
jupyter
notebook
pandas==1.2.0
statsmodels==0.12.1
pandas==2.2.2
statsmodels==0.14.2
scipy
patsy==0.5.1
patsy==0.5.6
numpy
plotly-geo
psutil
Expand Down
2 changes: 1 addition & 1 deletion doc/python/3d-volume.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ np.random.seed(0)
l = 30
X, Y, Z = np.mgrid[:l, :l, :l]
vol = np.zeros((l, l, l))
pts = (l * np.random.rand(3, 15)).astype(np.int)
pts = (l * np.random.rand(3, 15)).astype(int)
vol[tuple(indices for indices in pts)] = 1
from scipy import ndimage
vol = ndimage.gaussian_filter(vol, 4)
Expand Down
24 changes: 14 additions & 10 deletions doc/python/axes.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ fig.show()

*New in 5.19*

If `tickangle` is not explicitly set, its default value is `auto`, meaning if the label needs to be rotated to avoid labels overlapping, it will rotate by either 30 or 90 degrees. Using `autotickangles`, you can also specify a list of angles for `tickangle` to use. If `tickangle` is `auto` and you provide a list of angles to `autotickangles`, the label angle will be set to the first value in the list that prevents overlap.
If `tickangle` is not explicitly set, its default value is `auto`, meaning if the label needs to be rotated to avoid labels overlapping, it will rotate by either 30 or 90 degrees. Using `autotickangles`, you can also specify a list of angles for `tickangle` to use. If `tickangle` is `auto` and you provide a list of angles to `autotickangles`, the label angle will be set to the first value in the list that prevents overlap.

```python
import plotly.express as px
Expand All @@ -390,14 +390,18 @@ Here is an example.
import plotly.graph_objects as go
import pandas as pd

# Load and filter Apple stock data for 2016
apple_df = pd.read_csv(
"https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv",
parse_dates=["Date"],
index_col="Date"
"https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv"
)

apple_df_2016 = apple_df["2016"]
# Convert 'Date' column to datetime format
apple_df['Date'] = pd.to_datetime(apple_df['Date'])

# Set 'Date' column as index
apple_df.set_index('Date', inplace=True)

# Filter for 2016
apple_df_2016 = apple_df.loc['2016']

# Create figure and add line
fig = go.Figure()
Expand Down Expand Up @@ -599,7 +603,7 @@ fig.show()

*New in 5.17*

You can also set just a lower or upper bound manually and have autorange applied to the other bound by setting it to `None`. In the following example, we set a an upper bound of 4.5 on the x axes, while specifying `None` for the lower bound, meaning it will use autorange. On the y axes, we set the lower bound, and use `None` for the upper bound, meaning that uses autorange.
You can also set just a lower or upper bound manually and have autorange applied to the other bound by setting it to `None`. In the following example, we set a an upper bound of 4.5 on the x axes, while specifying `None` for the lower bound, meaning it will use autorange. On the y axes, we set the lower bound, and use `None` for the upper bound, meaning that uses autorange.

```python
import plotly.express as px
Expand Down Expand Up @@ -857,7 +861,7 @@ fig.show()

#### <code>nonnegative</code>, <code>tozero</code>, and <code>normal</code> Rangemode

When you don't specify a range, autorange is used. It's also used for bounds set to `None` when providing a `range`.
When you don't specify a range, autorange is used. It's also used for bounds set to `None` when providing a `range`.

The axis auto-range calculation logic can be configured using the `rangemode` axis parameter.

Expand Down Expand Up @@ -898,7 +902,7 @@ fig.update_xaxes(autorangeoptions=dict(maxallowed=5))
fig.show()
```

##### Clip Minimum and Maximum
##### Clip Minimum and Maximum

You can also clip an axis range at a specific maximum or minimum value with `autorangeoptions.clipmax` and `autorangeoptions.clipmin`.

Expand All @@ -916,7 +920,7 @@ fig.show()

##### Specify Values to be Included

Use `autorangeoptions.include` to specify a value that should always be included within the calculated autorange. In this example, we specify that for the autorange calculated on the x-axis, 5 should be included.
Use `autorangeoptions.include` to specify a value that should always be included within the calculated autorange. In this example, we specify that for the autorange calculated on the x-axis, 5 should be included.

```python
import plotly.express as px
Expand Down
12 changes: 6 additions & 6 deletions doc/python/box-plots.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,12 @@ x_data = ['Carmelo Anthony', 'Dwyane Wade',

N = 50

y0 = (10 * np.random.randn(N) + 30).astype(np.int)
y1 = (13 * np.random.randn(N) + 38).astype(np.int)
y2 = (11 * np.random.randn(N) + 33).astype(np.int)
y3 = (9 * np.random.randn(N) + 36).astype(np.int)
y4 = (15 * np.random.randn(N) + 31).astype(np.int)
y5 = (12 * np.random.randn(N) + 40).astype(np.int)
y0 = (10 * np.random.randn(N) + 30).astype(int)
y1 = (13 * np.random.randn(N) + 38).astype(int)
y2 = (11 * np.random.randn(N) + 33).astype(int)
y3 = (9 * np.random.randn(N) + 36).astype(int)
y4 = (15 * np.random.randn(N) + 31).astype(int)
y5 = (12 * np.random.randn(N) + 40).astype(int)

y_data = [y0, y1, y2, y3, y4, y5]

Expand Down
9 changes: 5 additions & 4 deletions doc/python/icicle-charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
Levels are given starting from the bottom to the top of the hierarchy,
ie the last level corresponds to the root.
"""
df_all_trees = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
df_list = []
for i, level in enumerate(levels):
df_tree = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
dfg = df.groupby(levels[i:]).sum()
Expand All @@ -317,11 +317,12 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
df_tree['parent'] = 'total'
df_tree['value'] = dfg[value_column]
df_tree['color'] = dfg[color_columns[0]] / dfg[color_columns[1]]
df_all_trees = df_all_trees.append(df_tree, ignore_index=True)
df_list.append(df_tree)
total = pd.Series(dict(id='total', parent='',
value=df[value_column].sum(),
color=df[color_columns[0]].sum() / df[color_columns[1]].sum()))
df_all_trees = df_all_trees.append(total, ignore_index=True)
color=df[color_columns[0]].sum() / df[color_columns[1]].sum()), name=0)
df_list.append(total)
df_all_trees = pd.concat(df_list, ignore_index=True)
return df_all_trees


Expand Down
4 changes: 2 additions & 2 deletions doc/python/mixed-subplots.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ df = pd.read_csv(
)

# frequency of Country
freq = df
freq = freq.Country.value_counts().reset_index().rename(columns={"index": "x"})
freq = df['Country'].value_counts().reset_index()
freq.columns = ['x', 'Country']

# read in 3d volcano surface data
df_v = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/volcano.csv")
Expand Down
3 changes: 1 addition & 2 deletions doc/python/ml-regression.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split

df = px.data.tips()
X = df.total_bill[:, None]
X = df.total_bill.to_numpy()[:, None]
X_train, X_test, y_train, y_test = train_test_split(X, df.tip, random_state=0)

model = LinearRegression()
Expand All @@ -129,7 +129,6 @@ model.fit(X_train, y_train)
x_range = np.linspace(X.min(), X.max(), 100)
y_range = model.predict(x_range.reshape(-1, 1))


fig = go.Figure([
go.Scatter(x=X_train.squeeze(), y=y_train, name='train', mode='markers'),
go.Scatter(x=X_test.squeeze(), y=y_test, name='test', mode='markers'),
Expand Down
9 changes: 5 additions & 4 deletions doc/python/sunburst-charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
Levels are given starting from the bottom to the top of the hierarchy,
ie the last level corresponds to the root.
"""
df_all_trees = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
df_list = []
for i, level in enumerate(levels):
df_tree = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
dfg = df.groupby(levels[i:]).sum()
Expand All @@ -367,11 +367,12 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
df_tree['parent'] = 'total'
df_tree['value'] = dfg[value_column]
df_tree['color'] = dfg[color_columns[0]] / dfg[color_columns[1]]
df_all_trees = df_all_trees.append(df_tree, ignore_index=True)
df_list.append(df_tree)
total = pd.Series(dict(id='total', parent='',
value=df[value_column].sum(),
color=df[color_columns[0]].sum() / df[color_columns[1]].sum()))
df_all_trees = df_all_trees.append(total, ignore_index=True)
color=df[color_columns[0]].sum() / df[color_columns[1]].sum()), name=0)
df_list.append(total)
df_all_trees = pd.concat(df_list, ignore_index=True)
return df_all_trees


Expand Down
17 changes: 9 additions & 8 deletions doc/python/treemaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ When the argument of `color` corresponds to non-numerical data, discrete colors
```python
import plotly.express as px
df = px.data.tips()
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
values='total_bill', color='day')
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
fig.show()
Expand All @@ -101,7 +101,7 @@ In the example below the color of Saturday and Sunday sectors is the same as Din
```python
import plotly.express as px
df = px.data.tips()
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
values='total_bill', color='time')
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
fig.show()
Expand All @@ -114,7 +114,7 @@ For more information about discrete colors, see the [dedicated page](/python/dis
```python
import plotly.express as px
df = px.data.tips()
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
values='total_bill', color='time',
color_discrete_map={'(?)':'lightgrey', 'Lunch':'gold', 'Dinner':'darkblue'})
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
Expand Down Expand Up @@ -241,7 +241,7 @@ fig = go.Figure(go.Treemap(
labels = labels,
values = values,
parents = parents,
marker_colors = ["pink", "royalblue", "lightgray", "purple",
marker_colors = ["pink", "royalblue", "lightgray", "purple",
"cyan", "lightgray", "lightblue", "lightgreen"]
))

Expand Down Expand Up @@ -316,7 +316,7 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
Levels are given starting from the bottom to the top of the hierarchy,
ie the last level corresponds to the root.
"""
df_all_trees = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
df_list = []
for i, level in enumerate(levels):
df_tree = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
dfg = df.groupby(levels[i:]).sum()
Expand All @@ -328,11 +328,12 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
df_tree['parent'] = 'total'
df_tree['value'] = dfg[value_column]
df_tree['color'] = dfg[color_columns[0]] / dfg[color_columns[1]]
df_all_trees = df_all_trees.append(df_tree, ignore_index=True)
df_list.append(df_tree)
total = pd.Series(dict(id='total', parent='',
value=df[value_column].sum(),
color=df[color_columns[0]].sum() / df[color_columns[1]].sum()))
df_all_trees = df_all_trees.append(total, ignore_index=True)
color=df[color_columns[0]].sum() / df[color_columns[1]].sum()), name=0)
df_list.append(total)
df_all_trees = pd.concat(df_list, ignore_index=True)
return df_all_trees


Expand Down
27 changes: 13 additions & 14 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ ipywidgets==7.7.2
jupyter-client<7
jupyter
notebook
pandas==1.2.0
statsmodels==0.12.1
scipy==1.5.4
patsy==0.5.1
numpy==1.19.5
pandas==2.2.2
statsmodels==0.14.2
scipy==1.13.0
patsy==0.5.6
numpy==1.26.4
plotly-geo
igraph
geopandas==0.8.1
pyshp==2.1.2
shapely==1.7.1
geopandas==0.14.3
pyshp==2.3.1
shapely==2.0.4
psutil
requests
networkx==2.6.3
networkx==3.3
squarify
scikit-image==0.18.1
scikit-image==0.23.2
scikit-learn
sphinx==3.5.4
sphinxcontrib-applehelp==1.0.2
Expand All @@ -31,7 +31,7 @@ sphinx_bootstrap_theme
recommonmark
pathlib
python-frontmatter
datashader==0.14.4
datashader==0.16.1
pyarrow
cufflinks==0.17.3
kaleido
Expand All @@ -42,7 +42,6 @@ nbconvert==5.6.1
orjson
dash-bio
jinja2<3.1
parmed<=3.4.4; python_version<"3.8"
dask==2022.2.0
dask==2024.4.2
polars
geoparse<=2.0.3
xarray==2022.9.0