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

Refactored matplotlib ElementPlots by adding higher-level API #438

Merged
merged 34 commits into from
Feb 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d75e8ec
Initial refactor of matplotlib ElementPlots
philippjfr Feb 3, 2016
f9bfa2b
Fixed updating of CurvePlots
philippjfr Feb 3, 2016
b52b793
Fixed bug in matplotlib HeatMapPlot
philippjfr Feb 3, 2016
dd1796a
Fixed extent in matplotlib RasterPlot
philippjfr Feb 3, 2016
c277426
Fixed key bug in ElementPlot.initialize_plot
philippjfr Feb 3, 2016
f4340c0
Fixed VectorFieldPlot updating
philippjfr Feb 3, 2016
b5dba89
Merge branch 'master' into mpl_refactor
philippjfr Feb 13, 2016
25be363
Refactored matplotlib 3d plots
philippjfr Feb 13, 2016
68c85d7
Removed pointless constructors from mpl AnnotationPlots
philippjfr Feb 13, 2016
11bc626
Added style to mpl ElementPlot update_handles signature
philippjfr Feb 13, 2016
ab4e2b7
Removed superfluous DrawPlot in mpl backend
philippjfr Feb 13, 2016
09ac3a1
Removed key from ElementPlot.update_handles signature
philippjfr Feb 13, 2016
c9bf7a5
Added method to teardown existing matplotlib handles
philippjfr Feb 13, 2016
9a53751
Refactored seaborn plots
philippjfr Feb 13, 2016
e099503
Fixed TablePlot.update_handles after refactor
philippjfr Feb 13, 2016
da0e7d9
Removed element argument from ElementPlot.init_artist signature
philippjfr Feb 13, 2016
9c9bbe7
Fixed syntax error in ErrorPlot
philippjfr Feb 13, 2016
17e2778
Fixed small bugs in plotting after refactor
philippjfr Feb 13, 2016
03e8c69
Readded key as an argument to mpl ElementPlot.update_handles
philippjfr Feb 14, 2016
8614435
Refactored mpl PointPlot and Scatter3D plot implementations
philippjfr Feb 14, 2016
dc72c98
Fixes for updating mpl plots
philippjfr Feb 14, 2016
bc4f9b1
Fix for mpl VectorFieldPlot
philippjfr Feb 14, 2016
40cd397
Fix for mpl Layout titles
philippjfr Feb 14, 2016
5142e7b
Cast VectorField angles to list to avoid comparison warnings
philippjfr Feb 14, 2016
aec1b7d
Fixed py3 bug in mpl ElementPlot
philippjfr Feb 14, 2016
003e9b7
Fixed VectorField scaling issues
philippjfr Feb 14, 2016
912fd47
Temporary fix for mpl PointPlot color handling
philippjfr Feb 14, 2016
728f710
Refactored mpl VectorFieldPlot
philippjfr Feb 15, 2016
2849297
Renamed ElementPlot.init_artist to init_artists
philippjfr Feb 16, 2016
6ba4ab5
Made mpl ElementPlot.get_data return types consistent
philippjfr Feb 16, 2016
3cb60b5
Minor cleanup in Scatter3DPlot
philippjfr Feb 16, 2016
aadfdbb
Avoid setting label in mpl plots if none is supplied
philippjfr Feb 16, 2016
ebeac23
A number of fixes for Seaborn plots
philippjfr Feb 16, 2016
901b316
Further fixes for Point and Scatter3D color styling
philippjfr Feb 16, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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