Closed robroc closed 4 years ago
Yes, you can use .update_yaxes(matches=None)
... note that this will break the Y-axis linkage for all plots, even within rows, not just across them:
import plotly.express as px
df = px.data.tips()
fig = px.scatter(df, x="total_bill", y="tip", facet_row="day", facet_col="time")
fig.update_yaxes(matches=None)
fig.show()
This works, but my second facet lacks a y scale which is now important... any way to add one?
EDIT: to answer my own question:
fig.update_yaxes(showticklabels=True, col=2) # assuming second facet
What about an option like ggplot2::facet_grid
's space
argument, such that width will be proportional to the length of the scale?
Is it possible when doing fig.update_yaxes(matches=None)
to make the width of each xaxis facet proportional to range of the axis?
Here's an example notebook where facets are all the same size and not spaced relative to x-axis range.
Yes, you can use
.update_yaxes(matches=None)
... note that this will break the Y-axis linkage for all plots, even within rows, not just across them: [...]
Is there also something similar to seaborns sharey="row"
option which shares the y axis in the same row but not across them?
It seems like it is possible in the normal plotly (shared_yaxes = True/"rows"
) or in plotly express possible by setting the matches attribute on all axes manually but that is not scalable and requires manual intervention should some of the underlying layout or faceting count change...
fig.layout.yaxis.matches = 'y'
fig.layout.yaxis2.matches = 'y'
fig.layout.yaxis3.matches = 'y'
@septatrix you can use fig.update_yaxes(matches='y')
to set this value across all y-axes, regardless how many y-axes there are.
Then however it would also sync the y axis across different rows which is not what I desire. I have both facet_row
and facet_col
and the y axis should be matches for plots in the same row but not between the rows themselves (as the scale would be off by a large factor)
Ah, right. I was just saying if you want to set them all to "y" you can. To get per-row matching is more complex because you need each yaxis to be matched with the lowest-numbered yaxis on its row, say. And there's no one liner for that atm.
Is there a way to make the y-axis on faceted plots independent, like in Plotly's
shared_yaxes = False
option, or Seaborn's FacetGridsharey = False
?