Skip to content

Commit

Permalink
Fixes for matplotlib and bokeh plots
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Apr 25, 2017
1 parent df0ba89 commit c77cdd7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
26 changes: 20 additions & 6 deletions geoviews/plotting/bokeh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
from bokeh.models import WMTSTileSource
from bokeh.models.tools import BoxZoomTool

from holoviews import Store
from holoviews import Store, Overlay, NdOverlay
from holoviews.core import util
from holoviews.core.options import SkipRendering, Options
from holoviews.plotting.bokeh.annotation import TextPlot
from holoviews.plotting.bokeh.element import ElementPlot
from holoviews.plotting.bokeh.element import ElementPlot, OverlayPlot as HvOverlayPlot
from holoviews.plotting.bokeh.chart import PointPlot
from holoviews.plotting.bokeh.path import PolygonPlot, PathPlot
from holoviews.plotting.bokeh.raster import RasterPlot

from ...element import (WMTS, Points, Polygons, Path, Shape, Image,
Feature, is_geographic, Text)
Feature, is_geographic, Text, _Element)
from ...operation import project_image
from ...util import project_extents, geom_to_array

Expand All @@ -37,7 +37,8 @@ class GeoPlot(ElementPlot):
BoxZoomTool(match_aspect=True), 'reset'],
doc="A list of plugin tools to use on the plot.")

show_grid = param.Boolean(default=False)
show_grid = param.Boolean(default=True, doc="""
Whether to show a gridlines on the plot.""")

def __init__(self, element, **params):
super(GeoPlot, self).__init__(element, **params)
Expand All @@ -62,6 +63,18 @@ def get_extents(self, element, ranges):
return (np.NaN,)*4 if not extents else extents


class OverlayPlot(HvOverlayPlot):
"""
Subclasses the HoloViews OverlayPlot to add custom behavior
for geographic plots.
"""

def __init__(self, element, **params):
self.geographic = any(element.traverse(is_geographic, [_Element]))
if self.geographic:
self.show_grid = False
super(OverlayPlot, self).__init__(element, **params)


class TilePlot(GeoPlot):

Expand Down Expand Up @@ -229,7 +242,9 @@ def get_extents(self, element, ranges=None):
Shape: GeoShapePlot,
Image: GeoRasterPlot,
Feature: FeaturePlot,
Text: GeoTextPlot}, 'bokeh')
Text: GeoTextPlot,
Overlay: OverlayPlot,
NdOverlay: OverlayPlot}, 'bokeh')

options = Store.options(backend='bokeh')

Expand All @@ -242,4 +257,3 @@ def get_extents(self, element, ranges=None):
options.Feature.Lakes = Options('style', fill_color='#97b6e1', line_color='#97b6e1')
options.Feature.Rivers = Options('style', line_color='#97b6e1')
options.Shape = Options('style', line_color='black', fill_color='#30A2DA')

5 changes: 1 addition & 4 deletions geoviews/plotting/mpl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,7 @@ def update_handles(self, *args):
"""
Update the elements of the plot.
"""
if self.geographic:
return GeoPlot.update_handles(self, *args)
else:
return super(GeoImagePlot, self).update_handles(*args)
return GeoPlot.update_handles(self, *args)


class GeoPointPlot(GeoPlot, PointPlot):
Expand Down

0 comments on commit c77cdd7

Please sign in to comment.