示例#1
0
    def test_mpl_bokeh_output_options_group_expandable(self):
        original_allowed_kws = Options._output_allowed_kws[:]
        Options._output_allowed_kws = ['backend', 'file_format_example']
        # Re-register
        Store.register({Curve: plotting.mpl.CurvePlot}, 'matplotlib')
        Store.register({Curve: plotting.bokeh.CurvePlot}, 'bokeh')

        curve_bk = Options('Curve', backend='bokeh', color='blue')
        curve_mpl = Options('Curve', backend='matplotlib', color='red',
                            file_format_example='SVG')
        c = Curve([1,2,3])
        styled = c.opts(curve_bk, curve_mpl)
        self.assertEqual(Store.lookup_options('matplotlib', styled, 'output').kwargs,
                         {'backend':'matplotlib', 'file_format_example':'SVG'})

        self.assertEqual(Store.lookup_options('bokeh', styled, 'output').kwargs,
                         {})
        Options._output_allowed_kws = original_allowed_kws
示例#2
0
        if element.crs:
            x, y = DEFAULT_PROJ.transform_point(element.x, element.y,
                                                element.crs)
        return (dict(x=[x], y=[y], text=[element.text]), mapping)

    def get_extents(self, element, ranges=None):
        return None, None, None, None


Store.register(
    {
        WMTS: TilePlot,
        Points: GeoPointPlot,
        Polygons: GeoPolygonPlot,
        Path: GeoPathPlot,
        Shape: GeoShapePlot,
        Image: GeoRasterPlot,
        Feature: FeaturePlot,
        Text: GeoTextPlot,
        Overlay: OverlayPlot,
        NdOverlay: OverlayPlot
    }, 'bokeh')

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

options.Feature = Options('style', line_color='black')
options.Feature.Coastline = Options('style', line_width=0.5)
options.Feature.Borders = Options('style', line_width=0.5)
options.Feature.Rivers = Options('style', line_color='blue')
options.Feature.Land = Options('style',
                               fill_color='#efefdb',
示例#3
0
            X, Y, Theta, Sf_0 = edges[1, :].real+.5, edges[0, :].real+.5, np.pi -  edges[2, :].real, edges[3, :].real
            weights = edges[4, :]

            weights = weights/(np.abs(weights)).max()

            for x, y, theta, sf_0, weight in zip(X, Y, Theta, Sf_0, weights):
                u_, v_ = np.cos(theta)*scale/sf_0*self.shape[0], np.sin(theta)*scale/sf_0*self.shape[1]
                segment = [(x - u_, y - v_), (x + u_, y + v_)]
                segments.append(segment)
                colors.append((0, 0, 0, 1))# black
                linewidths.append(linewidth) # *weight thinning byalpha...

            # TODO : put circle in front
            n_ = np.sqrt(self.shape[0]**2+self.shape[1]**2)
            for x, y, theta, sf_0, weight in zip(X, Y, Theta, Sf_0, weights):
                fc = (0, 0, 0, 1)# black
                # http://matplotlib.sourceforge.net/users/transforms_tutorial.html
                circ = patches.Circle((x,y), self.scale_circle*scale/sf_0*n_, facecolor=fc, edgecolor='none')
                ax.add_patch(circ)

            line_segments = LineCollection(segments, linewidths=linewidths, colors=colors, linestyles='solid')
            ax.add_collection(line_segments)

        ax.axis([0, self.shape[0], self.shape[1], 0])

        return ax


Store.register({ChevronHistogram: ChevronPlot}, 'matplotlib')
示例#4
0
Compositor.register(compositor)

Store.register(
    {
        WMTS: TilePlot,
        Points: GeoPointPlot,
        Labels: GeoLabelsPlot,
        VectorField: GeoVectorFieldPlot,
        Polygons: GeoPolygonPlot,
        Contours: GeoContourPlot,
        Rectangles: GeoRectanglesPlot,
        Segments: GeoSegmentsPlot,
        Path: GeoPathPlot,
        Shape: GeoShapePlot,
        Image: GeoRasterPlot,
        RGB: GeoRGBPlot,
        LineContours: LineContourPlot,
        FilledContours: FilledContourPlot,
        Feature: FeaturePlot,
        HexTiles: HexTilesPlot,
        Text: GeoTextPlot,
        Overlay: GeoOverlayPlot,
        NdOverlay: GeoOverlayPlot,
        Graph: GeoGraphPlot,
        TriMesh: GeoTriMeshPlot,
        Nodes: GeoPointPlot,
        EdgePaths: GeoPathPlot,
        QuadMesh: GeoQuadMeshPlot
    }, 'bokeh')

options = Store.options(backend='bokeh')
示例#5
0
class BlochSpherePlot(Plot3D):

    projection = param.String(default='3d')

    label_conventions = param.String(default='xyz')

    xaxis, yaxis = None, None

    style_opts = ['font_color', 'font_size', 'frame_alpha', 'frame_color',
                  'point_color', 'point_marker', 'point_size', 'sphere_alpha',
                  'sphere_color', 'vector_style', 'vector_mutation']

    def get_data(self, element, ranges, style):
        return (element.data,), style, {}

    def teardown_handles(self):
        self.handles['axis'].cla()

    def init_artists(self, ax, plot_data, plot_kwargs):
        sphere=Bloch(axes=ax, fig=self.handles['fig'])
        for k, v in plot_kwargs.items():
            setattr(sphere, k, v)
        sphere.add_vectors(*plot_data)
        sphere.set_label_convention(self.label_conventions)
        sphere.make_sphere()
        return {'artist': sphere}


Store.register({BlochSphere: BlochSpherePlot}, 'matplotlib')
示例#6
0
        return (dict(x=[x], y=[y], text=[element.text]), mapping, style)

    def get_extents(self, element, ranges=None):
        return None, None, None, None



Store.register({WMTS: TilePlot,
                Points: GeoPointPlot,
                VectorField: GeoVectorFieldPlot,
                Polygons: GeoPolygonPlot,
                Contours: GeoContourPlot,
                Path: GeoPathPlot,
                Shape: GeoShapePlot,
                Image: GeoRasterPlot,
                RGB: GeoRGBPlot,
                Feature: FeaturePlot,
                Text: GeoTextPlot,
                Overlay: OverlayPlot,
                NdOverlay: OverlayPlot,
                Graph: GeoGraphPlot,
                TriMesh: GeoTriMeshPlot,
                Nodes: GeoPointPlot,
                EdgePaths: GeoPathPlot,
                QuadMesh: GeoQuadMeshPlot}, 'bokeh')

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

options.Feature = Options('style', line_color='black')
options.Feature.Coastline = Options('style', line_width=0.5)
options.Feature.Borders = Options('style', line_width=0.5)
options.Feature.Rivers = Options('style', line_color='blue')
示例#7
0
文件: __init__.py 项目: ioam/geoviews
    transfer_options=True, transfer_parameters=True, backends=['bokeh']
)
Compositor.register(compositor)


Store.register({WMTS: TilePlot,
                Points: GeoPointPlot,
                Labels: GeoLabelsPlot,
                VectorField: GeoVectorFieldPlot,
                Polygons: GeoPolygonPlot,
                Contours: GeoContourPlot,
                Path: GeoPathPlot,
                Shape: GeoShapePlot,
                Image: GeoRasterPlot,
                RGB: GeoRGBPlot,
                LineContours: LineContourPlot,
                FilledContours: FilledContourPlot,
                Feature: FeaturePlot,
                HexTiles: HexTilesPlot,
                Text: GeoTextPlot,
                Overlay: GeoOverlayPlot,
                NdOverlay: GeoOverlayPlot,
                Graph: GeoGraphPlot,
                TriMesh: GeoTriMeshPlot,
                Nodes: GeoPointPlot,
                EdgePaths: GeoPathPlot,
                QuadMesh: GeoQuadMeshPlot}, 'bokeh')

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

options.Feature = Options('style', line_color='black')
options.Feature.Coastline = Options('style', line_width=0.5)