Skip to content

Commit

Permalink
Fixed small bugs in plotting after refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Feb 13, 2016
1 parent 9c9bbe7 commit 192f63e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 40 deletions.
7 changes: 3 additions & 4 deletions holoviews/plotting/mpl/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def get_data(self, element, ranges, style):
cdim = element.get_dimension(self.color_index)
color = style.pop('color', None)
if cdim:
cs = points.dimension_values(self.color_index)
cs = element.dimension_values(self.color_index)
style['c'] = cs
if 'clim' not in style:
clims = ranges[cdim.name]
Expand All @@ -549,8 +549,7 @@ def get_data(self, element, ranges, style):
edgecolor = style.pop('edgecolors', style.pop('edgecolor', 'none'))

if element.get_dimension(self.size_index):
style['s'] = self._compute_size(points, style)

style['s'] = self._compute_size(element, style)

style['edgecolors'] = style.pop('edgecolors', 'none')
return (xs, ys), style, {}
Expand Down Expand Up @@ -971,7 +970,7 @@ def get_data(self, element, ranges, style):
cdim = element.get_dimension(self.color_index)
if cdim:
array = element.dimension_values(cdim)
clim = ranges[cdim]
clim = ranges[cdim.name]
style['array'] = array
style['clim'] = clim
return [data], style, {}
Expand Down
22 changes: 11 additions & 11 deletions holoviews/plotting/mpl/chart3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,18 @@ class Scatter3DPlot(Plot3D, PointPlot):
Index of the dimension from which the sizes will the drawn.""")

def get_data(self, element, ranges, style):
xs, ys, zs = (points.dimension_values(i) for i in range(3))
xs, ys, zs = (element.dimension_values(i) for i in range(3))

style = self.style[self.cyclic_index]
cdim = points.get_dimension(self.color_index)
cdim = element.get_dimension(self.color_index)
if cdim and 'cmap' in style:
cs = points.dimension_values(self.color_index)
cs = element.dimension_values(self.color_index)
style['c'] = cs
if 'clim' not in style:
clims = ranges[cdim.name]
style.update(vmin=clims[0], vmax=clims[1])
if points.get_dimension(self.size_index):
style['s'] = self._compute_size(points, style)
if element.get_dimension(self.size_index):
style['s'] = self._compute_size(element, style)

return (xs, ys, zs), style, {}

Expand All @@ -130,18 +130,18 @@ def init_artist(self, ax, plot_data, plot_kwargs):
ax.add_collection(scatterplot)
return {'artist': scatterplot}

def update_handles(self, axis, points, ranges, style):
def update_handles(self, axis, element, ranges, style):
artist = self.handles['artist']
offsets, style, plot_kwargs = self.get_data(points, ranges, style)
offsets, style, plot_kwargs = self.get_data(element, ranges, style)
artist._offsets3d = offsets
cdim = points.get_dimension(self.color_index)
cdim = element.get_dimension(self.color_index)
if cdim and 'cmap' in style:
cs = points.dimension_values(cdim)
cs = element.dimension_values(cdim)
clim = style['clim'] if 'clim' in style else ranges[cdim.name]
cmap = cm.get_cmap(style['cmap'])
artist._facecolor3d = map_colors(cs, clim, cmap, False)
if points.get_dimension(self.size_index):
artist.set_sizes(self._compute_size(points, style))
if element.get_dimension(self.size_index):
artist.set_sizes(self._compute_size(element, style))
return plot_kwargs


Expand Down
32 changes: 7 additions & 25 deletions holoviews/plotting/mpl/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ def update_frame(self, key, ranges=None):
subplot.update_frame(key, ranges=ranges)
axis = self.handles['axis']
self.update_handles(axis, self.layout, ranges, style)
if self.show_title:
title = self._format_title(key)
if 'title' in self.handles:
self.handles['title'].set_text(title)
else:
title = axis.set_title(title, **self._fontsize('title'))
self.handles['title'] = title



Expand Down Expand Up @@ -441,20 +448,6 @@ def _readjust_axes(self, axis):
self._adjust_subplots(self.handles['axis'], self.subaxes)


def update_handles(self, axis, view, ranges, style):
"""
Should be called by the update_frame class to update
any handles on the plot.
"""
if self.show_title:
title = self._format_title(key)
if 'title' in self.handles:
self.handles['title'].set_text(title)
else:
title = axis.set_title(title, **self._fontsize('title'))
self.handles['title'] = title


def _layout_axis(self, layout, axis):
fig = self.handles['fig']
axkwargs = {'gid': str(self.position)} if axis else {}
Expand Down Expand Up @@ -1036,19 +1029,8 @@ def _create_subplots(self, layout, positions, layout_dimensions, ranges, axes={}
return subplots, adjoint_clone, projections


def update_handles(self, axis, view, ranges, style):
"""
Should be called by the update_frame class to update
any handles on the plot.
"""
if self.show_title and 'title' in self.handles and len(self.coords) > 1:
self.handles['title'].set_text(self._format_title(key))


def initialize_plot(self):
axis = self.handles['axis']
self.update_handles(axis, None, None, None)

ranges = self.compute_ranges(self.layout, self.keys[-1], None)
for subplot in self.subplots.values():
subplot.initialize_plot(ranges=ranges)
Expand Down

0 comments on commit 192f63e

Please sign in to comment.