Skip to content

Update docs to version 5.17 #4360

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 39 commits into from
Sep 15, 2023
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d79add7
remove duplicate example
LiamConnors Jul 21, 2023
092e8ba
Update to_plotly_json docstring, and implement helper method to creat…
itsluketwist Jul 28, 2023
07b4593
Method rename and removal to ensure consistency.
itsluketwist Aug 2, 2023
d56abff
add examples for new autorangeoptions and
LiamConnors Aug 2, 2023
3fe31cf
format code
LiamConnors Aug 2, 2023
31034e3
Update 3d-axes.md
LiamConnors Aug 2, 2023
eae0c14
Merge branch 'master' into feature/update-json-funcs
itsluketwist Aug 11, 2023
831be15
Fix facet_col and animation_frame in px.imshow for xarrays.
Karl-Krauth Aug 17, 2023
b35dc73
Add changelog entry.
Karl-Krauth Aug 17, 2023
7ef805c
Use faster plotly.io serialization.
itsluketwist Aug 18, 2023
76be0e9
Merge branch 'master' into feature/update-json-funcs
itsluketwist Aug 18, 2023
b750692
Move changelog entry to unreleased section.
Karl-Krauth Aug 19, 2023
d833fd5
Update CHANGELOG.md
alexcjohnson Aug 19, 2023
9b904c5
Clean up imports and docstrings for consistency.
itsluketwist Aug 21, 2023
43d0432
Update `to_plotly_json` docstrings, add to CHANGELOG.md.
itsluketwist Aug 22, 2023
c838fec
Merge pull request #4331 from Karl-Krauth/imshow-xarray-bugfixes
alexcjohnson Aug 22, 2023
01bbae9
Merge branch 'master' into feature/update-json-funcs
alexcjohnson Aug 22, 2023
b4e307c
Merge pull request #4301 from itsluketwist/feature/update-json-funcs
alexcjohnson Aug 22, 2023
c757d28
Corrected minor type in heading ('RBG' -> 'RGB')
mwcoleman Aug 24, 2023
975a704
Merge pull request #4339 from mwcoleman/imshow-docs-typo
alexcjohnson Aug 24, 2023
9b3b592
Merge branch 'master' into autorange-bounds
LiamConnors Sep 8, 2023
f782065
Update Plotly.js version to 2.26.0
LiamConnors Sep 8, 2023
b51748c
Update axes.md
LiamConnors Sep 8, 2023
5b7874c
fix version number
LiamConnors Sep 8, 2023
9047c62
Update config.yml
LiamConnors Sep 8, 2023
11b4936
Merge pull request #4350 from plotly/upgrade-browsertools
LiamConnors Sep 8, 2023
a52af48
Merge branch 'master' into autorange-bounds
LiamConnors Sep 11, 2023
22681bc
Update CHANGELOG.md
LiamConnors Sep 12, 2023
581b753
add example with "max reversed"
LiamConnors Sep 12, 2023
40101cb
Update 3d-axes.md
LiamConnors Sep 12, 2023
871d065
Update 3d-axes.md
LiamConnors Sep 12, 2023
b2ebf8b
Merge pull request #4307 from plotly/autorange-bounds
LiamConnors Sep 15, 2023
bce8845
version changes for v5.17.0
LiamConnors Sep 15, 2023
7d005be
Merge pull request #4356 from plotly/release-5.17.0
alexcjohnson Sep 15, 2023
dae12d0
update versions to 5.17.0
LiamConnors Sep 15, 2023
d9d89e3
Merge pull request #4358 from plotly/update-docs-5-17
alexcjohnson Sep 15, 2023
f620d79
Update getting-started.md
LiamConnors Sep 15, 2023
e1b2d29
Merge branch 'master' into update-docs-5-17
LiamConnors Sep 15, 2023
59cdd99
Merge pull request #4359 from plotly/update-docs-5-17
alexcjohnson Sep 15, 2023
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
Prev Previous commit
Next Next commit
add examples for new autorangeoptions and
  • Loading branch information
LiamConnors committed Aug 2, 2023
commit d56abff5a1b44fdacb71abdde6e5dee5cbfd4eef
146 changes: 126 additions & 20 deletions doc/python/axes.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ fig.show()

#### Setting the Range of Axes Manually

The visible x and y axis range can be configured manually by setting the `range` axis property to a list of two values, the lower and upper boundary.
The visible x and y axis range can be configured manually by setting the `range` axis property to a list of two values, the lower and upper bound.

Here's an example of manually specifying the x and y axis range for a faceted scatter plot created with Plotly Express.

Expand All @@ -559,6 +559,41 @@ fig.update_yaxes(range=[3, 9])
fig.show()
```

#### Setting only a Lower or Upper Bound for Range

*New in 5.16*

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
df = px.data.iris()

fig = px.scatter(df, x="sepal_width", y="sepal_length", facet_col="species")
fig.update_xaxes(range=[None, 4.5])
fig.update_yaxes(range=[3, None])

fig.show()
```

#### Setting a Maximum and Minimum Allowed Axis Value

*New in 5.16*

When setting a range manually, you can also set a `maxallowed` or `minallowed` for an axis. With this set, you won't be able to pan further than the min or max allowed. In this example, we've set the minimum allowed on the x-axis to 1 and the maximum allowed on the y-axis to 10.

```python
import plotly.express as px

df = px.data.iris()

fig = px.scatter(df, x="sepal_width", y="sepal_length")
fig.update_xaxes(range=[1.5, 4.5], minallowed=1)
fig.update_yaxes(range=[3, 9], maxallowed=10)

fig.show()
```

#### Disabling Pan/Zoom on Axes (Fixed Range)

Pan/Zoom can be disabled for a given axis by setting `fixedrange` to `True`.
Expand Down Expand Up @@ -693,6 +728,22 @@ fig.update_yaxes(range=[9, 3])
fig.show()
```

*New in 5.16*

To use a reversed axis while specifying only an upper or lower bound for the range, set `autorange="reversed"`:

```python
import plotly.express as px
df = px.data.iris()

fig = px.scatter(df, x="sepal_width", y="sepal_length", facet_col="species")
fig.update_yaxes(range=[9, None],
autorange="reversed"
)

fig.show()
```

### Axis range for log axis type

If you are using a `log` type of axis and you want to set the range of the axis, you have to give the `log10` value of the bounds when using `fig.update_xaxes` or `fig.update_layout`. However, with `plotly.express` functions you pass directly the values of the range bounds (`plotly.express` then computes the appropriate values to pass to the figure layout).
Expand All @@ -717,25 +768,6 @@ fig.update_yaxes(type="log")
fig.show()
```

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

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

If `rangemode` is `"normal"` (the default), the range is computed based on the min and max values of the input data. If `"tozero"`, the range will always include zero. If `"nonnegative"`, the range will not extend below zero, regardless of the input data.

Here is an example of configuring a faceted scatter plot created using Plotly Express to always include zero for both the x and y axes.

```python
import plotly.express as px
df = px.data.iris()

fig = px.scatter(df, x="sepal_width", y="sepal_length", facet_col="species")
fig.update_xaxes(rangemode="tozero")
fig.update_yaxes(rangemode="tozero")

fig.show()
```

#### Setting the domain of the axis

```python
Expand Down Expand Up @@ -773,6 +805,80 @@ fig.update_xaxes(matches='x')
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`.

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

If `rangemode` is `"normal"` (the default), the range is computed based on the min and max values of the input data. If `"tozero"`, the range will always include zero. If `"nonnegative"`, the range will not extend below zero, regardless of the input data.

Here is an example of configuring a faceted scatter plot created using Plotly Express to always include zero for both the x and y axes.

```python
import plotly.express as px
df = px.data.iris()

fig = px.scatter(df, x="sepal_width", y="sepal_length", facet_col="species")
fig.update_xaxes(rangemode="tozero")
fig.update_yaxes(rangemode="tozero")

fig.show()
```

#### Autorange Options

*New in 5.16*

You can further configure how autorange is applied using `autorangeoptions` to specify maximum or minimum values or values to include.

##### Specifying Minimum and Maximum Allowed Values

Using `autorangeoptions.maxallowed`, you can specify an exact value to use as the autorange maximum. With `autorangeoptions.minallowed`, you can specify an exact value to use as the autorange minimum.

```python
import plotly.express as px

df = px.data.iris()

fig = px.scatter(df, x="sepal_width", y="sepal_length")
fig.update_yaxes(autorangeoptions=dict(minallowed=3))
fig.update_xaxes(autorangeoptions=dict(maxallowed=5))

fig.show()
```

##### Clip Minimum and Maximum

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

```python
import plotly.express as px

df = px.data.iris()

fig = px.scatter(df, x="sepal_width", y="sepal_length")
fig.update_yaxes(autorangeoptions=dict(clipmin=5))
fig.update_xaxes(autorangeoptions=dict(clipmax=4))

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.

```python
import plotly.express as px

df = px.data.iris()

fig = px.scatter(df, x="sepal_width", y="sepal_length")
fig.update_xaxes(autorangeoptions=dict(include=5))

fig.show()
```

#### Reference

See https://plotly.com/python/reference/layout/xaxis/ and https://plotly.com/python/reference/layout/yaxis/ for more information and chart attribute options!