Skip to content

Commit

Permalink
Merge pull request #438 from ioam/mpl_refactor
Browse files Browse the repository at this point in the history
Refactored matplotlib ElementPlots by adding higher-level API
  • Loading branch information
jlstevens committed Feb 16, 2016
2 parents 15d38ba + 901b316 commit 5c0a001
Show file tree
Hide file tree
Showing 11 changed files with 438 additions and 677 deletions.
4 changes: 2 additions & 2 deletions holoviews/plotting/mpl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def grid_selector(grid):
# Raster plots
QuadMesh: QuadMeshPlot,
Raster: RasterPlot,
HeatMap: RasterPlot,
HeatMap: HeatMapPlot,
Image: RasterPlot,
RGB: RasterPlot,
HSV: RasterPlot,
Expand Down Expand Up @@ -177,7 +177,7 @@ def grid_selector(grid):
options.Bars = Options('style', ec='k', color=Cycle())
options.Histogram = Options('style', ec='k', facecolor=Cycle())
options.Points = Options('style', color=Cycle(), marker='o')
options.Scatter3D = Options('style', facecolors=Cycle(), marker='o')
options.Scatter3D = Options('style', c=Cycle(), marker='o')
options.Scatter3D = Options('plot', fig_size=150)
options.Surface = Options('plot', fig_size=150)
options.Spikes = Options('style', color='black')
Expand Down
22 changes: 2 additions & 20 deletions holoviews/plotting/mpl/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,19 @@ def initialize_plot(self, ranges=None):
self.handles['annotations'] = handles
return self._finalize_axis(key, ranges=ranges)


def update_handles(self, axis, annotation, key, ranges=None):
def update_handles(self, key, axis, annotation, ranges, style):
# Clear all existing annotations
for element in self.handles['annotations']:
element.remove()

self.handles['annotations']=[]
opts = self.style[self.cyclic_index]
self.handles['annotations'] = self.draw_annotation(axis, annotation.data, opts)
self.handles['annotations'] = self.draw_annotation(axis, annotation.data, style)


class VLinePlot(AnnotationPlot):
"Draw a vertical line on the axis"

style_opts = ['alpha', 'color', 'linewidth', 'linestyle', 'visible']

def __init__(self, annotation, **params):
super(VLinePlot, self).__init__(annotation, **params)

def draw_annotation(self, axis, position, opts):
return [axis.axvline(position, **opts)]

Expand All @@ -55,9 +49,6 @@ class HLinePlot(AnnotationPlot):

style_opts = ['alpha', 'color', 'linewidth', 'linestyle', 'visible']

def __init__(self, annotation, **params):
super(HLinePlot, self).__init__(annotation, **params)

def draw_annotation(self, axis, position, opts):
"Draw a horizontal line on the axis"
return [axis.axhline(position, **opts)]
Expand All @@ -68,9 +59,6 @@ class TextPlot(AnnotationPlot):

style_opts = ['alpha', 'color', 'family', 'weight', 'rotation', 'fontsize', 'visible']

def __init__(self, annotation, **params):
super(TextPlot, self).__init__(annotation, **params)

def draw_annotation(self, axis, data, opts):
(x,y, text, fontsize,
horizontalalignment, verticalalignment, rotation) = data
Expand All @@ -90,9 +78,6 @@ class ArrowPlot(AnnotationPlot):

style_opts = sorted(set(_arrow_style_opts + _text_style_opts))

def __init__(self, annotation, **params):
super(ArrowPlot, self).__init__(annotation, **params)

def draw_annotation(self, axis, data, opts):
direction, text, xy, points, arrowstyle = data
arrowprops = dict({'arrowstyle':arrowstyle},
Expand All @@ -113,9 +98,6 @@ class SplinePlot(AnnotationPlot):

style_opts = ['alpha', 'edgecolor', 'linewidth', 'linestyle', 'visible']

def __init__(self, annotation, **params):
super(SplinePlot, self).__init__(annotation, **params)

def draw_annotation(self, axis, data, opts):
verts, codes = data
patch = patches.PathPatch(matplotlib.path.Path(verts, codes),
Expand Down
Loading

0 comments on commit 5c0a001

Please sign in to comment.