Skip to content

Commit

Permalink
Merge pull request #1269 from ioam/mpl_finalize
Browse files Browse the repository at this point in the history
Passed Element to mpl ElementPlot._finalize_axis
  • Loading branch information
jlstevens authored Apr 11, 2017
2 parents 71d8bda + b026502 commit c6629c1
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion holoviews/plotting/mpl/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def initialize_plot(self, ranges=None):
with abbreviated_exception():
handles = self.draw_annotation(axis, annotation.data, opts)
self.handles['annotations'] = handles
return self._finalize_axis(key, ranges=ranges)
return self._finalize_axis(key, element=annotation, ranges=ranges)

def update_handles(self, key, axis, annotation, ranges, style):
# Clear all existing annotations
Expand Down
4 changes: 2 additions & 2 deletions holoviews/plotting/mpl/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def initialize_plot(self, ranges=None):
ticks = self._compute_ticks(hist, edges, widths, lims)
ax_settings = self._process_axsettings(hist, lims, ticks)

return self._finalize_axis(self.keys[-1], ranges=el_ranges, **ax_settings)
return self._finalize_axis(self.keys[-1], ranges=el_ranges, element=hist, **ax_settings)


def _process_hist(self, hist):
Expand Down Expand Up @@ -801,7 +801,7 @@ def initialize_plot(self, ranges=None):

self.handles['artist'], self.handles['xticks'], xdims = self._create_bars(axis, element)
return self._finalize_axis(key, ranges=ranges, xticks=self.handles['xticks'],
dimensions=[xdims, vdim])
element=element, dimensions=[xdims, vdim])


def _finalize_ticks(self, axis, element, xticks, yticks, zticks):
Expand Down
16 changes: 10 additions & 6 deletions holoviews/plotting/mpl/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def __init__(self, element, **params):
self.warning("Plotting hook %r could not be applied:\n\n %s" % (hook, e))


def _finalize_axis(self, key, title=None, dimensions=None, ranges=None, xticks=None,
def _finalize_axis(self, key, element=None, title=None, dimensions=None, ranges=None, xticks=None,
yticks=None, zticks=None, xlabel=None, ylabel=None, zlabel=None):
"""
Applies all the axis settings before the axis or figure is returned.
Expand All @@ -141,7 +141,8 @@ def _finalize_axis(self, key, title=None, dimensions=None, ranges=None, xticks=N
When the number of the frame is supplied as n, this method looks
up and computes the appropriate title, axis labels and axis bounds.
"""
element = self._get_frame(key)
if element is None:
element = self._get_frame(key)
self.current_frame = element
if not dimensions and element and not self.subplots:
el = element.traverse(lambda x: x, [Element])
Expand Down Expand Up @@ -462,7 +463,8 @@ def update_frame(self, key, ranges=None, element=None):
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)
self._finalize_axis(key, ranges=ranges, **(axis_kwargs if axis_kwargs else {}))
self._finalize_axis(key, element=element, ranges=ranges,
**(axis_kwargs if axis_kwargs else {}))


@mpl_rc_context
Expand All @@ -486,7 +488,8 @@ def initialize_plot(self, ranges=None):
handles = self.init_artists(ax, plot_data, plot_kwargs)
self.handles.update(handles)

return self._finalize_axis(self.keys[-1], ranges=ranges, **axis_kwargs)
return self._finalize_axis(self.keys[-1], element=element, ranges=ranges,
**axis_kwargs)


def init_artists(self, ax, plot_args, plot_kwargs):
Expand Down Expand Up @@ -831,7 +834,8 @@ def initialize_plot(self, ranges=None):
if self.show_legend:
self._adjust_legend(element, axis)

return self._finalize_axis(key, ranges=ranges, title=self._format_title(key))
return self._finalize_axis(key, element=element, ranges=ranges,
title=self._format_title(key))


def update_frame(self, key, ranges=None, element=None):
Expand Down Expand Up @@ -866,4 +870,4 @@ def update_frame(self, key, ranges=None, element=None):
if self.show_legend:
self._adjust_legend(element, axis)

self._finalize_axis(key, ranges=ranges)
self._finalize_axis(key, element=element, ranges=ranges)
3 changes: 2 additions & 1 deletion holoviews/plotting/mpl/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def initialize_plot(self, ranges=None):
if 'fig' in self.handles and self.handles['fig'] != plt.gcf():
self.handles['fig'] = plt.gcf()

return self._finalize_axis(self.keys[-1], **self.get_axis_kwargs(element))
return self._finalize_axis(self.keys[-1], element=element,
**self.get_axis_kwargs(element))


def _process_style(self, style):
Expand Down
4 changes: 2 additions & 2 deletions holoviews/plotting/mpl/seaborn.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def initialize_plot(self, ranges=None):
if 'fig' in self.handles and self.handles['fig'] != plt.gcf():
self.handles['fig'] = plt.gcf()

return self._finalize_axis(self.keys[-1])
return self._finalize_axis(self.keys[-1], element=dfview)


def _process_style(self, styles):
Expand Down Expand Up @@ -272,7 +272,7 @@ def update_frame(self, key, ranges=None):

axis_kwargs = self.update_handles(key, axis, element, key, ranges, style)
if axis:
self._finalize_axis(key, **(axis_kwargs if axis_kwargs else {}))
self._finalize_axis(key, element=element, **(axis_kwargs if axis_kwargs else {}))


def _update_plot(self, axis, view, style):
Expand Down
2 changes: 1 addition & 1 deletion holoviews/plotting/mpl/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def initialize_plot(self, ranges=None):

self.handles['artist'] = table

return self._finalize_axis(self.keys[-1])
return self._finalize_axis(self.keys[-1], element=element)


def update_handles(self, key, axis, element, ranges, style):
Expand Down

0 comments on commit c6629c1

Please sign in to comment.