plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

When only one value is set for `xaxis.range`, the other value becomes invalid.

Open trouver opened this issue 1 year ago • 0 comments

If one of the values for xaxis.range is set to None, the other set value will not take effect. Both values for xaxis.range need to be set simultaneously to be effective. The same issue does not occur with yaxis.range.

In the following code, setting the first value of xaxis.range to None and the second value to 100 does not set the x-axis range to [0, 100].

import plotly.express as px


df = {'fruit': ['banana', 'orange', 'apple'], 'price': [10, 20, 30]}
fig = px.bar(df, x='price', y='fruit')
fig.update_layout(xaxis={'range': [None, 100]})
fig.show()

fig1

In the code below, with both values of xaxis.range set, it works correctly.

import plotly.express as px


df = {'fruit': ['banana', 'orange', 'apple'], 'price': [10, 20, 30]}
fig = px.bar(df, x='price', y='fruit')
fig.update_layout(xaxis={'range': [0, 100]})
fig.show()

fig2

Test Environment:

OS: Windows 10 Python Version: 3.12.4 Plotly Version: 5.23.0

trouver avatar Aug 19 '24 03:08 trouver