Skip to content
Permalink
Browse files

Merge df71cba into 3b997dc

  • Loading branch information...
philippjfr committed Nov 5, 2018
2 parents 3b997dc + df71cba commit 2906f78c1cede63b153f8a71fae3a00814c540aa
Showing with 44 additions and 26 deletions.
  1. +1 −5 holoviews/plotting/bokeh/raster.py
  2. +2 −2 holoviews/plotting/mpl/__init__.py
  3. +41 −19 holoviews/plotting/mpl/raster.py
@@ -70,7 +70,7 @@ def get_data(self, element, ranges, style):



class RGBPlot(RasterPlot):
class RGBPlot(ElementPlot):

style_opts = ['alpha']
_plot_methods = dict(single='image_rgba')
@@ -113,10 +113,6 @@ def get_data(self, element, ranges, style):
data = dict(image=[img], x=[l], y=[b], dw=[dw], dh=[dh])
return (data, mapping, style)

def _glyph_properties(self, plot, element, source, ranges, style):
return ElementPlot._glyph_properties(self, plot, element,
source, ranges, style)



class HSVPlot(RGBPlot):
@@ -155,8 +155,8 @@ def grid_selector(grid):
False: HeatMapPlot},
True),
Image: RasterPlot,
RGB: RasterPlot,
HSV: RasterPlot,
RGB: RGBPlot,
HSV: RGBPlot,

# Graph Elements
Graph: GraphPlot,
@@ -5,43 +5,28 @@
from ...core import traversal
from ...core.util import match_spec, max_range, unique_iterator
from ...element.raster import Image, Raster, RGB
from .element import ColorbarPlot, OverlayPlot
from .element import ElementPlot, ColorbarPlot, OverlayPlot
from .plot import MPLPlot, GridPlot, mpl_rc_context
from .util import get_raster_array



class RasterPlot(ColorbarPlot):
class RasterBasePlot(ElementPlot):

aspect = param.Parameter(default='equal', doc="""
Raster elements respect the aspect ratio of the
Images by default but may be set to an explicit
aspect ratio or to 'square'.""")

clipping_colors = param.Dict(default={'NaN': 'transparent'})

colorbar = param.Boolean(default=False, doc="""
Whether to add a colorbar to the plot.""")

show_legend = param.Boolean(default=False, doc="""
Whether to show legend for the plot.""")

situate_axes = param.Boolean(default=True, doc="""
Whether to situate the image relative to other plots. """)

style_opts = ['alpha', 'cmap', 'interpolation', 'visible',
'filterrad', 'clims', 'norm']

_plot_methods = dict(single='imshow')

def __init__(self, *args, **kwargs):
super(RasterPlot, self).__init__(*args, **kwargs)
if self.hmap.type == Raster:
self.invert_yaxis = not self.invert_yaxis


def get_extents(self, element, ranges, range_type='combined'):
extents = super(RasterPlot, self).get_extents(element, ranges, range_type)
extents = super(RasterBasePlot, self).get_extents(element, ranges, range_type)
if self.situate_axes or range_type not in ('combined', 'data'):
return extents
else:
@@ -50,11 +35,22 @@ def get_extents(self, element, ranges, range_type='combined'):
else:
return element.extents


def _compute_ticks(self, element, ranges):
return None, None


class RasterPlot(RasterBasePlot, ColorbarPlot):

clipping_colors = param.Dict(default={'NaN': 'transparent'})

style_opts = ['alpha', 'cmap', 'interpolation', 'visible',
'filterrad', 'clims', 'norm']

def __init__(self, *args, **kwargs):
super(RasterPlot, self).__init__(*args, **kwargs)
if self.hmap.type == Raster:
self.invert_yaxis = not self.invert_yaxis

def get_data(self, element, ranges, style):
xticks, yticks = self._compute_ticks(element, ranges)

@@ -98,6 +94,32 @@ def update_handles(self, key, axis, element, ranges, style):



class RGBPlot(RasterBasePlot):

style_opts = ['alpha', 'interpolation', 'visible', 'filterrad']

def get_data(self, element, ranges, style):
xticks, yticks = self._compute_ticks(element, ranges)
data = get_raster_array(element)
l, b, r, t = element.bounds.lbrt()
if self.invert_axes:
data = data[::-1, ::-1]
data = data.transpose([1, 0, 2])
l, b, r, t = b, l, t, r
style['extent'] = [l, r, b, t]
style['origin'] = 'upper'
return [data], style, {'xticks': xticks, 'yticks': yticks}

def update_handles(self, key, axis, element, ranges, style):
im = self.handles['artist']
data, style, axis_kwargs = self.get_data(element, ranges, style)
l, r, b, t = style['extent']
im.set_data(data[0])
im.set_extent((l, r, b, t))
return axis_kwargs



class QuadMeshPlot(ColorbarPlot):

clipping_colors = param.Dict(default={'NaN': 'transparent'})

0 comments on commit 2906f78

Please sign in to comment.
You can’t perform that action at this time.