Reputation: 1572
I am trying to plot a 3x3 sns.PairGrid
of plots. Currently, the axes are shared for the bottom triangle, and the upper triangle separately. Put another way, the x axes and y axes are only shared with their respective columns/row. So the x-axis of plot (1,0)
is shared with (0,0)
and (2,0)
.
However, I would like all the off-diagonal plots to share their axes. So for example, I want (1,0)
share its x-axis with (0,0)
and (2,0)
like before, but also with (0,1)
.
Also, I would prefer it if the y-axes aren't shared with the plots on the diagonal, as those are 1-D kernel density plots, and so if I share their y-axes, some of them will be invisible as the size of the probability density functions isn't the same.
Here's my current code if it helps:
The 3 parameters I am plotting against each other are called 'A', 'C', and 'logsw', and are contained in the pandas.DataFrame
called hyperparams
g = sns.PairGrid(hyperparams, diag_sharey=False)
g.map_lower(sns.kdeplot)
g.map_upper(plt.scatter, marker='+')
g.map_diag(sns.kdeplot)
And here's a trivial example of the output plot:
The images on the bottom left are scaled differently to the images on the upper right, which is what I'm trying to avoid.
Upvotes: 3
Views: 2777
Reputation: 1625
High level, you could manually set the x and y limits and tickmarks. You could also set variables to what you want to share and then just reuse the variable in the 3 like subplots.
That way, if you need to make an adjustment, you just update the variable and the 3 plots that share it now update all at once.
In the past, I created code for a Pair grid where I set the limits and ticks on all subplots along the y-axis, and all plots along the x-axis in this manner.
Upvotes: 2
Reputation: 49044
There is currently no way of automatically doing this in Seaborn. The workaround suggested in the comment that seems to have solve the problem is to set the axes limits manually for the diagonal subplots. Using variables for the x and y limits ensures that they only need to be changed in one place when updating the axes ranges.
Upvotes: 1