diff --git a/doc/source/whatsnew/v2.1.0.rst b/doc/source/whatsnew/v2.1.0.rst index 5477694941125..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`) -- Groupby/resample/rolling ^^^^^^^^^^^^^^^^^^^^^^^^ 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] 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(