Skip to content

Commit

Permalink
compat: Matplotlib 3.10.0 (#6431)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Nov 1, 2024
1 parent 1d4bdee commit 9400f82
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
18 changes: 14 additions & 4 deletions holoviews/plotting/mpl/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .chart import AreaPlot, ChartPlot
from .path import PolygonPlot
from .plot import AdjoinedPlot
from .util import MPL_GE_3_9_0
from .util import MPL_GE_3_9_0, MPL_GE_3_10_0


class DistributionPlot(AreaPlot):
Expand Down Expand Up @@ -84,7 +84,10 @@ def get_data(self, element, ranges, style):
style['labels'] = labels
style = {k: v for k, v in style.items()
if k not in ['zorder', 'label']}
style['vert'] = not self.invert_axes
if MPL_GE_3_10_0:
style["orientation"] = "horizontal" if self.invert_axes else "vertical"
else:
style["vert"] = not self.invert_axes
format_kdims = [kd.clone(value_format=None) for kd in element.kdims]
return (data,), style, {'dimensions': [format_kdims, element.vdims[0]]}

Expand Down Expand Up @@ -171,11 +174,15 @@ def init_artists(self, ax, plot_args, plot_kwargs):
artists = ax.violinplot(*plot_args, bw_method=bw_method,
showmedians=showmedians, **plot_kwargs)
if self.inner == 'box':
if MPL_GE_3_10_0:
invert_axes = {"orientation": "horizontal" if self.invert_axes else "vertical"}
else:
invert_axes = {"vert": not self.invert_axes}
box = ax.boxplot(*plot_args, positions=plot_kwargs['positions'],
showfliers=False, showcaps=False, patch_artist=True,
boxprops={'facecolor': box_color},
medianprops={'color': 'white'}, widths=0.1,
**labels)
**invert_axes, **labels)
artists.update(box)
for body, color in zip(artists['bodies'], facecolors):
body.set_facecolors(color)
Expand Down Expand Up @@ -220,7 +227,10 @@ def get_data(self, element, ranges, style):
new_style = self._apply_transforms(element, ranges, style)
style = {k: v for k, v in new_style.items()
if k not in ['zorder', 'label']}
style['vert'] = not self.invert_axes
if MPL_GE_3_10_0:
style["orientation"] = "horizontal" if self.invert_axes else "vertical"
else:
style["vert"] = not self.invert_axes
format_kdims = [kd.clone(value_format=None) for kd in element.kdims]
ticks = {'yticks' if self.invert_axes else 'xticks': list(enumerate(labels))}
return (data,), style, dict(dimensions=[format_kdims, element.vdims[0]], **ticks)
Expand Down
1 change: 1 addition & 0 deletions holoviews/plotting/mpl/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
MPL_VERSION = Version(mpl.__version__).release
MPL_GE_3_7_0 = MPL_VERSION >= (3, 7, 0)
MPL_GE_3_9_0 = MPL_VERSION >= (3, 9, 0)
MPL_GE_3_10_0 = MPL_VERSION >= (3, 10, 0)


def is_color(color):
Expand Down

0 comments on commit 9400f82

Please sign in to comment.