Pandas 3x3 Scatter Matrix Shortcuts

I am creating a pandas scatter matrix using the following code:

import numpy as np
import pandas as pd

a = np.random.normal(1, 3, 100)
b = np.random.normal(3, 1, 100)
c = np.random.normal(2, 2, 100)

df = pd.DataFrame({'A':a,'B':b,'C':c})
pd.scatter_matrix(df, diagonal='kde')

This result is in the following scattering matrix: enter image description here

The first row has no bright labels, the 3rd column without labels, the 3rd element "C" is not marked.

Any idea how to complete this story with missing shortcuts?

+5
source share
2 answers

Access the appropriate subplot and change its settings as follows.

axes = pd.scatter_matrix(df, diagonal='kde')
ax = axes[2, 2] # your bottom-right subplot
ax.xaxis.set_visible(True)
draw()

You can check how the scatter_matrix function relates to marking using the link below. If you do this over and over again, consider copying the code to a file and creating your own scatter_matrix function.

https://github.com/pydata/pandas/blob/master/pandas/tools/plotting.py#L160

:

, ax[0, 0].xaxis.set_visible(True) .., . - scal_matrix, , [2, 2], , . , , , .

, if :

if i == 0
if i == n-1
if j == 0
if j == n-1

. , , .

+5

, Google:

n = len(features)

for x in range(n):
    for y in range(n):
        sax = axes[x, y]
        if ((x%2)==0) and (y==0):
            if not sax.get_ylabel():
                sax.set_ylabel(features[-1])       
            sax.yaxis.set_visible(True)

        if (x==(n-1)) and ((y%2)==0):
            sax.xaxis.set_visible(True)

        if ((x%2)==1) and (y==(n-1)):
            if not sax.get_ylabel():
                sax.set_ylabel(features[-1])       
            sax.yaxis.set_visible(True)

        if (x==0) and ((y%2)==1):
            sax.xaxis.set_visible(True)

-

+1

All Articles