Iβm using the option marginal_y = "rug"
in px.scatter()
and I like it a lot. It only takes up a bit too much space / width. Is there a possibility to reduce the width of the rug section next to the plot?
Hi @DeLaRiva, this is related to the xaxis domains. Take this example with two βrugsβ:
import plotly.express as px
df = px.data.iris()
fig = px.scatter(
df,
x="sepal_length",
y="sepal_width",
marginal_x="histogram",
marginal_y="rug"
)
fig.show()
Changing the xaxis domains of each xaxis:
fig.update_layout(
xaxis={'domain': [0.0,0.95]},
xaxis2={'domain': [0.96,1.0]},
xaxis3={'domain': [0.0,0.95]}
)
creates:
2 Likes
Perfect, thanks a lot!
Could you please also explain the values? I mean what do the two values inside the actually do?
An extract form the documents:
domain
Code: fig.update_xaxes(domain=list(...))
Type: list
Default: [0, 1]
Sets the domain of this axis (in plot fraction).
Basically (from my understanding):
- first float in the list: start of corresponding axis
- second float in the list: end of corresponding axis
in this case the main axis (xaxis) starts at 0% (left) and takes 95% of the plot, the second axis starts at 96% and ends at 100%. Thatβs the reason for the gap you see between main plot and right hand side rug.
1 Like