Skip to content

Commit

Permalink
unset marginal ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaskruchten committed Jun 25, 2020
1 parent e281bc9 commit 1e8d77a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 15 additions & 0 deletions packages/python/plotly/plotly/tests/test_core/test_px/test_px.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1e8d77a

Please sign in to comment.