diff --git a/CHANGELOG.md b/CHANGELOG.md index f6e9fdc370..8f534c70ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Fixed special cases with `px.sunburst` and `px.treemap` with `path` input ([#2524](https://github.com/plotly/plotly.py/pull/2524)) - Fixed bug in `hover_data` argument of `px` functions, when the column name is changed with labels and `hover_data` is a dictionary setting up a specific format for the hover data ([#2544](https://github.com/plotly/plotly.py/pull/2544)). - Made the Plotly Express `trendline` argument more robust and made it work with datetime `x` values ([#2554](https://github.com/plotly/plotly.py/pull/2554)) +- Plotly Express `range_(x|y)` should not impact the unlinked range of marginal subplots ([#2600](https://github.com/plotly/plotly.py/pull/2600)) ## [4.8.1] - 2020-05-28 diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index d89794a5a4..93fba6eefb 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -543,14 +543,18 @@ def configure_cartesian_marginal_axes(args, fig, orders): # Configure axis ticks on marginal subplots if args["marginal_x"]: - fig.update_yaxes(showticklabels=False, showline=False, ticks="", row=nrows) + fig.update_yaxes( + showticklabels=False, showline=False, ticks="", range=None, row=nrows + ) if args["template"].layout.yaxis.showgrid is None: fig.update_yaxes(showgrid=args["marginal_x"] == "histogram", row=nrows) if args["template"].layout.xaxis.showgrid is None: fig.update_xaxes(showgrid=True, row=nrows) if args["marginal_y"]: - fig.update_xaxes(showticklabels=False, showline=False, ticks="", col=ncols) + fig.update_xaxes( + showticklabels=False, showline=False, ticks="", range=None, col=ncols + ) if args["template"].layout.xaxis.showgrid is None: fig.update_xaxes(showgrid=args["marginal_y"] == "histogram", col=ncols) if args["template"].layout.yaxis.showgrid is None: diff --git a/packages/python/plotly/plotly/tests/test_core/test_px/test_px.py b/packages/python/plotly/plotly/tests/test_core/test_px/test_px.py index 21b8b0ba0b..d037bc10b5 100644 --- a/packages/python/plotly/plotly/tests/test_core/test_px/test_px.py +++ b/packages/python/plotly/plotly/tests/test_core/test_px/test_px.py @@ -238,3 +238,18 @@ def test_permissive_defaults(): msg = "'PxDefaults' object has no attribute 'should_not_work'" with pytest.raises(AttributeError, match=msg): px.defaults.should_not_work = "test" + + +def test_marginal_ranges(): + df = px.data.tips() + fig = px.scatter( + df, + x="total_bill", + y="tip", + marginal_x="histogram", + marginal_y="histogram", + range_x=[5, 10], + range_y=[5, 10], + ) + assert fig.layout.xaxis2.range is None + assert fig.layout.yaxis3.range is None