From a457a48bc80268aa3eb0be8c18f9d62b489e7a29 Mon Sep 17 00:00:00 2001 From: Ben Pedigo Date: Thu, 28 Sep 2023 10:19:52 -0700 Subject: [PATCH] Fixed Matplotlib 3.8 compatibility issues (#1049) * specify angle as kwarg * try removing some maybe unnecessary code? * fight with mypy * black * fix sorts * try switch to explain * fix intersphinx * other instances of wrong tutorial intersphinx --- graspologic/layouts/render.py | 4 ++-- graspologic/plot/plot.py | 38 ++++++++++++++++----------------- graspologic/plot/plot_matrix.py | 10 ++++----- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/graspologic/layouts/render.py b/graspologic/layouts/render.py index a3acacddd..9975e67b0 100644 --- a/graspologic/layouts/render.py +++ b/graspologic/layouts/render.py @@ -127,9 +127,9 @@ def _draw_graph( for source, target in graph.edges(): edge_color_list.append(node_colors[source]) - ax.set_xbound(x_domain) + ax.set_xbound(*x_domain) ax.set_xlim(x_domain) - ax.set_ybound(y_domain) + ax.set_ybound(*y_domain) ax.set_ylim(y_domain) nx.draw_networkx_edges( diff --git a/graspologic/plot/plot.py b/graspologic/plot/plot.py index 6b3cdec4b..efa80e061 100644 --- a/graspologic/plot/plot.py +++ b/graspologic/plot/plot.py @@ -2,7 +2,7 @@ # Licensed under the MIT License. import warnings -from typing import Any, Collection, Optional, Union +from typing import Any, Collection, Literal, Optional, Union import matplotlib as mpl import matplotlib.axes @@ -442,7 +442,7 @@ def gridplot( Set of colors for mapping the ``hue`` variable. If a dict, keys should be values in the ``hue`` variable. For acceptable string arguments, see the palette options at - :doc:`Choosing Colormaps in Matplotlib ` + :doc:`Choosing Colormaps in Matplotlib ` alpha : float [0, 1], default : 0.7 Alpha value of plotted gridplot points sizes : length 2 tuple, default: (10, 200) @@ -607,7 +607,7 @@ def pairplot( Set of colors for mapping the ``hue`` variable. If a dict, keys should be values in the ``hue`` variable. For acceptable string arguments, see the palette options at - :doc:`Choosing Colormaps in Matplotlib `. + :doc:`Choosing Colormaps in Matplotlib `. alpha : float, optional, default: 0.7 Opacity value of plotter markers between 0 and 1 size : float or int, optional, default: 50 @@ -763,10 +763,10 @@ def _plot_ellipse_and_data( angle = np.arctan(u[1] / u[0]) angle = 180.0 * angle / np.pi ell = mpl.patches.Ellipse( - [mean[j], mean[k]], + (mean[j], mean[k]), v[0], v[1], - 180.0 + angle, + angle=180.0 + angle, color=cluster_palette[i], ) ell.set_clip_box(ax.bbox) @@ -984,7 +984,7 @@ def pairplot_with_gmm( handles, labels = axes[1].get_legend_handles_labels() fig.legend( handles, - labels, + labels, # type: ignore loc="center right", title=legend_name, ) @@ -1069,7 +1069,7 @@ def degreeplot( Set of colors for mapping the ``hue`` variable. If a dict, keys should be values in the ``hue`` variable. For acceptable string arguments, see the palette options at - :doc:`Choosing Colormaps in Matplotlib `. + :doc:`Choosing Colormaps in Matplotlib `. figsize : tuple of length 2, default (10, 5) Size of the figure (width, height) @@ -1138,7 +1138,7 @@ def edgeplot( Set of colors for mapping the ``hue`` variable. If a dict, keys should be values in the ``hue`` variable. For acceptable string arguments, see the palette options at - :doc:`Choosing Colormaps in Matplotlib `. + :doc:`Choosing Colormaps in Matplotlib `. figsize : tuple of length 2, default (10, 5) Size of the figure (width, height) @@ -1620,17 +1620,17 @@ def _plot_groups( axline_kws = dict(linestyle="dashed", lw=0.9, alpha=0.3, zorder=3, color="grey") # draw lines for x in inner_freq_cumsum[1:-1]: - ax.vlines(x, 0, n_verts + 1, **axline_kws) - ax.hlines(x, 0, n_verts + 1, **axline_kws) + ax.vlines(x, 0, n_verts + 1, **axline_kws) # type: ignore + ax.hlines(x, 0, n_verts + 1, **axline_kws) # type: ignore # add specific lines for the borders of the plot pad = 0.001 low = pad high = 1 - pad - ax.plot((low, low), (low, high), transform=ax.transAxes, **axline_kws) - ax.plot((low, high), (low, low), transform=ax.transAxes, **axline_kws) - ax.plot((high, high), (low, high), transform=ax.transAxes, **axline_kws) - ax.plot((low, high), (high, high), transform=ax.transAxes, **axline_kws) + ax.plot((low, low), (low, high), transform=ax.transAxes, **axline_kws) # type: ignore + ax.plot((low, high), (low, low), transform=ax.transAxes, **axline_kws) # type: ignore + ax.plot((high, high), (low, high), transform=ax.transAxes, **axline_kws) # type: ignore + ax.plot((low, high), (high, high), transform=ax.transAxes, **axline_kws) # type: ignore # generic curve that we will use for everything lx = np.linspace(-np.pi / 2.0 + 0.05, np.pi / 2.0 - 0.05, 500) @@ -1648,7 +1648,7 @@ def _plot_groups( # top inner curves ax_x = divider.new_vertical(size="5%", pad=0.0, pack_start=False) - ax.figure.add_axes(ax_x) + ax.figure.add_axes(ax_x) # type: ignore _plot_brackets( ax_x, np.tile(inner_unique, len(outer_unique)), @@ -1662,7 +1662,7 @@ def _plot_groups( ) # side inner curves ax_y = divider.new_horizontal(size="5%", pad=0.0, pack_start=True) - ax.figure.add_axes(ax_y) + ax.figure.add_axes(ax_y) # type: ignore _plot_brackets( ax_y, np.tile(inner_unique, len(outer_unique)), @@ -1679,7 +1679,7 @@ def _plot_groups( # top outer curves pad_scalar = 0.35 / 30 * fontsize ax_x2 = divider.new_vertical(size="5%", pad=pad_scalar, pack_start=False) - ax.figure.add_axes(ax_x2) + ax.figure.add_axes(ax_x2) # type: ignore _plot_brackets( ax_x2, outer_unique, @@ -1693,7 +1693,7 @@ def _plot_groups( ) # side outer curves ax_y2 = divider.new_horizontal(size="5%", pad=pad_scalar, pack_start=True) - ax.figure.add_axes(ax_y2) + ax.figure.add_axes(ax_y2) # type: ignore _plot_brackets( ax_y2, outer_unique, @@ -1715,7 +1715,7 @@ def _plot_brackets( tick_width: np.ndarray, curve: np.ndarray, level: str, - axis: str, + axis: Literal["both", "x", "y"], max_size: int, fontsize: int, ) -> None: diff --git a/graspologic/plot/plot_matrix.py b/graspologic/plot/plot_matrix.py index 832fc4e05..1382ab115 100644 --- a/graspologic/plot/plot_matrix.py +++ b/graspologic/plot/plot_matrix.py @@ -156,11 +156,11 @@ def _remove_shared_ax(ax): """ Remove ax from its sharex and sharey """ - # Remove ax from the Grouper object - shax = ax.get_shared_x_axes() - shay = ax.get_shared_y_axes() - shax.remove(ax) - shay.remove(ax) + # # Remove ax from the Grouper object + # shax = ax.get_shared_x_axes() + # shay = ax.get_shared_y_axes() + # shax.remove(ax) + # shay.remove(ax) # Set a new ticker with the respective new locator and formatter for axis in [ax.xaxis, ax.yaxis]: