Ejemplo n.º 1
0
class GeoTextPlot(GeoAnnotationPlot, TextPlot):
    "Draw the Text annotation object"

    def draw_annotation(self, axis, data, crs, opts):
        (x,y, text, fontsize,
         horizontalalignment, verticalalignment, rotation) = data
        opts['fontsize'] = fontsize
        x, y = axis.projection.transform_point(x, y, src_crs=crs)
        return [axis.text(x, y, text,
                          horizontalalignment=horizontalalignment,
                          verticalalignment=verticalalignment,
                          rotation=rotation, **opts)]



# Register plots with HoloViews
Store.register({Contours: GeoContourPlot,
                Image: GeoImagePlot,
                GeoFeature: GeoFeaturePlot,
                WMTS: WMTSPlot,
                GeoTiles: GeoTilePlot,
                Points: GeoPointPlot,
                Text: GeoTextPlot,
                Layout: LayoutPlot,
                Overlay: OverlayPlot}, 'matplotlib')


# Define plot and style options
opts = Store.options(backend='matplotlib')
OverlayPlot.aspect = 'equal'
Ejemplo n.º 2
0
Store.register({LineContours: LineContourPlot,
                FilledContours: FilledContourPlot,
                Image: GeoImagePlot,
                Feature: FeaturePlot,
                WMTS: WMTSPlot,
                Tiles: WMTSPlot,
                Points: GeoPointPlot,
                Labels: GeoLabelsPlot,
                VectorField: GeoVectorFieldPlot,
                Text: GeoTextPlot,
                Layout: LayoutPlot,
                NdLayout: LayoutPlot,
                Overlay: GeoOverlayPlot,
                Polygons: GeoPolygonPlot,
                Path: GeoPathPlot,
                Contours: GeoContourPlot,
                RGB: GeoRGBPlot,
                Shape: GeoShapePlot,
                Graph: GeoGraphPlot,
                TriMesh: GeoTriMeshPlot,
                Nodes: GeoPointPlot,
                EdgePaths: GeoPathPlot,
                HexTiles: GeoHexTilesPlot,
                QuadMesh: GeoQuadMeshPlot}, 'matplotlib')


# Define plot and style options
options = Store.options(backend='matplotlib')

options.Shape = Options('style', edgecolor='black', facecolor='#30A2DA')
Ejemplo n.º 3
0
import numpy as np
import holoviews as hv
hv.extension('bokeh', logo=False)
import param
import panel as pn
import matplotlib.pyplot as plt

from holoviews.operation.datashader import rasterize
from bokeh.models import WheelZoomTool
from holoviews.core import Store

valid_rgb_options = [
    k for group in ['style', 'plot', 'norm', 'output']
    for k in Store.options(backend='bokeh')['RGB'][group].allowed_keywords
]
valid_rgb_options.remove(
    'alpha')  # remove option set by sliders on individual channels

# TODO move to color module
import colorcet as cc

# repeat colormap to handle unint16 values
# needed to handle non continuous labels because colormap is stretched (and not cycled)
label_cmap = cc.b_glasbey_hv * 256


# bokeh hook workaround --> remove if holoviews finally handle this
def zoom_bounds_hook(bounds):
    '''restrict zooming out to given bounds'''
    def _hook(plot, element):
        plot.state.x_range.bounds = (bounds[0], bounds[2])