3
votes

I am doing a scatter matrix plot, but when I try to set the xlim and ylim, the diagonal terms of the plot get wrecked. My code is:

axS=scatter_matrix(dfS, alpha=0.5, figsize=(10, 10), 
diagonal='kde',color="black")
for i in range(5):
    for j in range(5):
        axS[i,j].set_xlim(0.0,1.0)
        axS[i,j].set_ylim(0.0,1.0)
plt.suptitle('Separable')
plt.show()

Without the limits (i.e. without the 'for i in range...'), the image I get is

Scatter Matrix without limits

Notice that the x and y limits are not the same in all the subplots.

Now, if I add the limits, the image I get is

Scatter Matrix with limits

Now I get to scale the same subplot to the same limits. However, neither the limit labels are right nor the diagonal plots.

Is there another way of setting the limits that won't mess the whole picture?

Thank you.

1

1 Answers

0
votes

The problem is that you actually don't want the y axis of your KDE plots to have the range (0,1).
Try this:

axS=scatter_matrix(dfS, alpha=0.5, figsize=(10, 10), 
diagonal='kde',color="black")
for i in range(5):
    for j in range(5):
        axS[i,j].set_xlim(0.0,1.0)
        if i != j:
             axS[i,j].set_ylim(0.0,1.0)
plt.suptitle('Separable')
plt.show()