Skip to content

Commit 1e7ac8d

Browse files
committed
Quick fix for matplotlib 3.10.* compatability
1 parent 36e9b78 commit 1e7ac8d

File tree

8 files changed

+17
-18
lines changed

8 files changed

+17
-18
lines changed

src/marsilea/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Declarative creation of composable visualization"""
22

3-
__version__ = "0.4.7"
3+
__version__ = "0.4.8"
44

55
import marsilea.plotter as plotter
66
from ._deform import Deformation

src/marsilea/base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,14 @@ def _legends_drawer(self, ax):
169169
for _, legs in legends.items():
170170
for leg in legs:
171171
try:
172+
# Try to detach legend from figure
172173
leg.remove()
174+
# For matplotlib >= 3.10.0
175+
if hasattr(leg, "_parent_figure"):
176+
setattr(leg, "_parent_figure", None)
177+
# For matplotlib < 3.10.0
178+
if hasattr(leg, "figure"):
179+
setattr(leg, "figure", None)
173180
except Exception:
174181
pass
175182

src/marsilea/plotter/arc.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,9 @@ def render_ax(self, spec):
231231
ax.set_ylim(lim * 1.1, 0)
232232
ax.set_xlim(0, 1)
233233
if self.side == "top":
234-
if not ax.yaxis_inverted():
235-
ax.invert_yaxis()
234+
ax.invert_yaxis()
236235
if self.side == "left":
237-
if not ax.xaxis_inverted():
238-
ax.invert_xaxis()
236+
ax.invert_xaxis()
239237
ax.set_axis_off()
240238

241239
def get_legends(self):

src/marsilea/plotter/area.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ def render_ax(self, spec):
9090
ax.plot(data, x, **line_options)
9191
ax.set_ylim(-0.5, len(data) - 0.5)
9292
if self.side == "left":
93-
if not ax.xaxis_inverted():
94-
ax.invert_xaxis()
93+
ax.invert_xaxis()
9594
else:
9695
ax.fill_between(x, data, **fill_options)
9796
if self.add_outline:

src/marsilea/plotter/bar.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,7 @@ def render_ax(self, spec):
270270
ax.xaxis.set_major_formatter(FuncFormatter(lambda x, p: f"{np.abs(x):g}"))
271271

272272
if self.is_flank:
273-
if not ax.yaxis_inverted():
274-
ax.invert_yaxis()
273+
ax.invert_yaxis()
275274

276275
if self.show_value:
277276
left_label = _format_labels(left_bar, self.fmt)

src/marsilea/plotter/bio.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,9 @@ def render_ax(self, spec):
171171
ax.set_xlim(0, lim)
172172
ax.set_ylim(0, data.shape[1])
173173
if self.is_flank:
174-
if not ax.yaxis_inverted():
175-
ax.invert_yaxis()
174+
ax.invert_yaxis()
176175
if self.side == "left":
177-
if not ax.xaxis_inverted():
178-
ax.invert_xaxis()
176+
ax.invert_xaxis()
179177
if self.side == "bottom":
180-
if not ax.yaxis_inverted():
181-
ax.invert_yaxis()
178+
ax.invert_yaxis()
182179
ax.set_axis_off()

src/marsilea/plotter/range.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ def render_ax(self, spec: RenderSpec):
125125
else:
126126
ax.set_xlim(0, len(data))
127127
if self.side == "left":
128-
if not ax.xaxis_inverted():
129-
ax.invert_xaxis()
128+
ax.invert_xaxis()
130129

131130
def get_legends(self):
132131
return [

src/marsilea/upset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ def _render_matrix(self, ax):
947947
def _extra_legends(self):
948948
handles = [Patch(**entry) for entry in self._legend_entries]
949949
highlight_legend = ListLegend(handles=handles, handlelength=2)
950-
highlight_legend.figure = None
950+
# highlight_legend.set_figure(None)
951951
return {"highlight_subsets": [highlight_legend]}
952952

953953
def render(self, figure=None, scale=1):

0 commit comments

Comments
 (0)