pythonaxesmirrorlimits

Why pairplot gives asymmetrical (different upper- and lower-triangle) plots when it should not?


I used a code like:

g = sns.pairplot(df.loc[:,['column1','column2','column3','column4','column5']])
g.map_offdiag(plt.hexbin, gridsize=(20,20))

and have a pairplot and I expect that upper- and lower- triangle plots to be mirrored. The plots look like this: enter image description here

I thought maybe the problems are the histograms so I tried to tighten the axes using plt.axis('tight') and plt.autoscale(enable=True, axis='y', tight=True) but nothing changed. I also got rid of the diagonal plots (made them invisible), but still the triangle plots are not mirrored. Why? and how to fix it?


Solution

  • Although still I do not understand why pairplot has this behavior here, I found a workaround. I access each plot within pairplot individually and set the limit manually.

    g.axes[I,J].set_ylim(df.column3.min(),df.column3.max())

    In this case, I had to repeat this piece of code 5 times, where I = 2 and J = 0,1,2,3,4.