From a446ea723d2f66b587c8e6398692e3f6b223ab72 Mon Sep 17 00:00:00 2001 From: julian048 Date: Fri, 11 Aug 2023 12:12:49 -0400 Subject: [PATCH 1/4] add grid functionality to scatter_matrix --- pandas/plotting/_matplotlib/misc.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pandas/plotting/_matplotlib/misc.py b/pandas/plotting/_matplotlib/misc.py index 1f9212587e05e..71a8e12fcad5f 100644 --- a/pandas/plotting/_matplotlib/misc.py +++ b/pandas/plotting/_matplotlib/misc.py @@ -102,11 +102,16 @@ def scatter_matrix( ax.set_xlabel(b) ax.set_ylabel(a) + if i != j: + ax.grid(grid) - if j != 0: - ax.yaxis.set_visible(False) - if i != n - 1: - ax.xaxis.set_visible(False) + if j != 0: # if its not on the left + ax.set_ylabel("") + ax.set_yticklabels([]) + + if i != n - 1: # if its not on the bottom + ax.set_xlabel("") + ax.set_xticklabels([]) if len(df.columns) > 1: lim1 = boundaries_list[0] From ca03eda3920d81a7405b54bf605ea43444f65310 Mon Sep 17 00:00:00 2001 From: julian048 Date: Fri, 11 Aug 2023 12:25:19 -0400 Subject: [PATCH 2/4] add doc to whats new documentation --- doc/source/whatsnew/v2.1.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v2.1.0.rst b/doc/source/whatsnew/v2.1.0.rst index 5477694941125..cd5a2724af710 100644 --- a/doc/source/whatsnew/v2.1.0.rst +++ b/doc/source/whatsnew/v2.1.0.rst @@ -795,7 +795,7 @@ Plotting ^^^^^^^^ - Bug in :meth:`Series.plot` when invoked with ``color=None`` (:issue:`51953`) - Fixed UserWarning in :meth:`DataFrame.plot.scatter` when invoked with ``c="b"`` (:issue:`53908`) -- +- Bug in :func:`scatter_matrix` where the ``grid`` parameter was ignored (:issue:`50818`) Groupby/resample/rolling ^^^^^^^^^^^^^^^^^^^^^^^^ From 8ef868a068a2e101a4bbbd89951ea832e58d30e2 Mon Sep 17 00:00:00 2001 From: julian048 Date: Fri, 11 Aug 2023 12:38:42 -0400 Subject: [PATCH 3/4] fix alphabetical order of doc --- doc/source/whatsnew/v2.1.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v2.1.0.rst b/doc/source/whatsnew/v2.1.0.rst index cd5a2724af710..a5222263a8177 100644 --- a/doc/source/whatsnew/v2.1.0.rst +++ b/doc/source/whatsnew/v2.1.0.rst @@ -793,9 +793,9 @@ Period Plotting ^^^^^^^^ +- Bug in :func:`scatter_matrix` where the ``grid`` parameter was ignored (:issue:`50818`) - Bug in :meth:`Series.plot` when invoked with ``color=None`` (:issue:`51953`) - Fixed UserWarning in :meth:`DataFrame.plot.scatter` when invoked with ``c="b"`` (:issue:`53908`) -- Bug in :func:`scatter_matrix` where the ``grid`` parameter was ignored (:issue:`50818`) Groupby/resample/rolling ^^^^^^^^^^^^^^^^^^^^^^^^ From 2bdeeee5b8866a5e794eeb9f1ce752b6e24a2079 Mon Sep 17 00:00:00 2001 From: julian048 Date: Fri, 11 Aug 2023 15:43:05 -0400 Subject: [PATCH 4/4] scattermatrix docstring to fit new expected output --- pandas/plotting/_misc.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pandas/plotting/_misc.py b/pandas/plotting/_misc.py index 625780ac9fc67..7d62ba287f717 100644 --- a/pandas/plotting/_misc.py +++ b/pandas/plotting/_misc.py @@ -206,15 +206,11 @@ def scatter_matrix( >>> df = pd.DataFrame(np.random.randn(1000, 4), columns=['A','B','C','D']) >>> pd.plotting.scatter_matrix(df, alpha=0.2) - array([[, , - , ], - [, , - , ], - [, , - , ], - [, , - , ]], - dtype=object) + array([[, , , ], + [, , , ], + [, , , ], + [, , + , ]], dtype=object) """ plot_backend = _get_plot_backend("matplotlib") return plot_backend.scatter_matrix(