Skip to content

Commit

Permalink
Fixed Matplotlib 3.8 compatibility issues (#1049)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bdpedigo committed Sep 28, 2023
1 parent 9663ff7 commit a457a48
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions graspologic/layouts/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
38 changes: 19 additions & 19 deletions graspologic/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 <tutorials/colors/colormaps>`
:doc:`Choosing Colormaps in Matplotlib <users/explain/colors/colormaps>`
alpha : float [0, 1], default : 0.7
Alpha value of plotted gridplot points
sizes : length 2 tuple, default: (10, 200)
Expand Down Expand Up @@ -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 <tutorials/colors/colormaps>`.
:doc:`Choosing Colormaps in Matplotlib <users/explain/colors/colormaps>`.
alpha : float, optional, default: 0.7
Opacity value of plotter markers between 0 and 1
size : float or int, optional, default: 50
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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 <tutorials/colors/colormaps>`.
:doc:`Choosing Colormaps in Matplotlib <users/explain/colors/colormaps>`.
figsize : tuple of length 2, default (10, 5)
Size of the figure (width, height)
Expand Down Expand Up @@ -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 <tutorials/colors/colormaps>`.
:doc:`Choosing Colormaps in Matplotlib <users/explain/colors/colormaps>`.
figsize : tuple of length 2, default (10, 5)
Size of the figure (width, height)
Expand Down Expand Up @@ -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)
Expand All @@ -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)),
Expand All @@ -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)),
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions graspologic/plot/plot_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit a457a48

Please sign in to comment.