Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for style updates in matplotlib #3442

Merged
merged 1 commit into from Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions holoviews/plotting/mpl/chart.py
Expand Up @@ -15,7 +15,7 @@
from ...core.util import (
OrderedDict, match_spec, unique_iterator, basestring, max_range,
isfinite, datetime_types, dt_to_int, dt64_to_dt, search_indices,
unique_array
unique_array, isscalar
)
from ...element import Raster, HeatMap
from ...operation import interpolate_curve
Expand Down Expand Up @@ -670,7 +670,10 @@ def update_handles(self, key, axis, element, ranges, style):
(xs, ys), style, _ = self.get_data(element, ranges, style)
paths.set_offsets(np.column_stack([xs, ys]))
if 's' in style:
paths.set_sizes(style['s'])
sizes = style['s']
if isscalar(sizes):
sizes = [sizes]
paths.set_sizes(sizes)
if 'vmin' in style:
paths.set_clim((style['vmin'], style['vmax']))
if 'c' in style:
Expand Down
4 changes: 4 additions & 0 deletions holoviews/plotting/mpl/element.py
Expand Up @@ -466,6 +466,10 @@ def update_frame(self, key, ranges=None, element=None):
ranges = self.compute_ranges(self.hmap, key, ranges)
ranges = util.match_spec(element, ranges)

max_cycles = self.style._max_cycles
style = self.lookup_options(element, 'style')
self.style = style.max_cycles(max_cycles) if max_cycles else style

label = element.label if self.show_legend else ''
style = dict(label=label, zorder=self.zorder, **self.style[self.cyclic_index])
axis_kwargs = self.update_handles(key, axis, element, ranges, style)
Expand Down
9 changes: 9 additions & 0 deletions holoviews/tests/plotting/matplotlib/testpointplot.py
Expand Up @@ -153,6 +153,15 @@ def test_points_padding_datetime_nonsquare(self):
self.assertEqual(y_range[0], 0.8)
self.assertEqual(y_range[1], 3.2)

def test_points_sizes_scalar_update(self):
hmap = HoloMap({i: Points([1, 2, 3]).opts(s=i*10) for i in range(1, 3)})
plot = mpl_renderer.get_plot(hmap)
artist = plot.handles['artist']
plot.update((1,))
self.assertEqual(artist.get_sizes(), np.array([10]))
plot.update((2,))
self.assertEqual(artist.get_sizes(), np.array([20]))

###########################
# Styling mapping #
###########################
Expand Down