Skip to content

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

Open
@trouver

Description

@trouver

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions