Skip to content

ENH: pandas.plotting.scatter_matrix to support plotting function hexbin in addition to scatter #56887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 of 3 tasks
shadiakiki1986 opened this issue Jan 15, 2024 · 1 comment
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member Visualization plotting

Comments

@shadiakiki1986
Copy link
Contributor

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

I wish I could use the scatter_matrix function to make hexbin plots

Feature Description

Add a new parameter nondiagonal to scatter_matrix to support hexbin instead of scatter

def scatter_matrix(...):
    ...
    if nondiagonal=="scatter":
        ax.scatter(...)
    if nondiagonal=="hexbin":
        ax.hexbin(...)
    ...

Alternative Solutions

Seaborn pairplot using kind = hist. Link: https://seaborn.pydata.org/generated/seaborn.pairplot.html

Additional Context

The general consensus on pandas.plotting.scatter_matrix is that "seaborn does this better" (ref 1, ref 2). Nevertheless, the functionality was kept, and the changes to support this feature are a few lines of code.

The quality of the plots can improve significantly. Here's an example with scatter:

# Copy of example from scatter_matrix docs page, but increase data frame rows from 1k to 10k:
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(1_0_000, 4), columns=['A','B','C','D'])

image

Same example with hexbin:

image

@giormala
Copy link
Contributor

Take

@giormala giormala removed their assignment May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member Visualization plotting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants