How to change pandas build integration?

I am trying to change the scatter_matrix graph to Pandas.

Simple use would be IRIS scatter matrix viz

Received:

iris = datasets.load_iris()
df = pd.DataFrame(iris.data, columns=iris.feature_names)
pd.tools.plotting.scatter_matrix(df, diagonal='kde', grid=False)
plt.show()

I want to make several modifications, including:

  • grid off control on all graphs
  • rotate x any y marks 90 degrees
  • disable ticks

Is there a way to change pandas' output without having to rewrite my own scatter plot function? where to start adding non-existent options, tweaks, etc.

Thank!

+4
source share
1 answer

pd.tools.plotting.scatter_matrix , ; [:,0] [-1,:]. . :

axs = pd.tools.plotting.scatter_matrix(df, diagonal='kde')

def wrap(txt, width=8):
    '''helper function to wrap text for long labels'''
    import textwrap
    return '\n'.join(textwrap.wrap(txt, width))

for ax in axs[:,0]: # the left boundary
    ax.grid('off', axis='both')
    ax.set_ylabel(wrap(ax.get_ylabel()), rotation=0, va='center', labelpad=20)
    ax.set_yticks([])

for ax in axs[-1,:]: # the lower boundary
    ax.grid('off', axis='both')
    ax.set_xlabel(wrap(ax.get_xlabel()), rotation=90)
    ax.set_xticks([])

scatter

+7

Source: https://habr.com/ru/post/1536077/


All Articles