Exemple #1
0
 def make_punchcard_plot(self, source):
     xdr = FactorRange(factors=source.data["hours"][::7])
     ydr = FactorRange(factors=source.data["days"][:7])
     title = "%s punchcard" % self.modelform.installer
     plot = Plot(title=title,
                 data_sources=[source],
                 x_range=xdr,
                 y_range=ydr,
                 width=600,
                 height=400)
     rect = Rect(x="hours",
                 y="days",
                 width=1,
                 height=1,
                 fill_color="red",
                 fill_alpha="percentages")
     rect_glyph = Glyph(data_source=source,
                        xdata_range=xdr,
                        ydata_range=ydr,
                        glyph=rect)
     plot.renderers.append(rect_glyph)
     hover = HoverTool(plot=plot, tooltips=dict(downloads="@counts"))
     plot.tools.append(hover)
     xaxis = CategoricalAxis(plot=plot, dimension=0)
     yaxis = CategoricalAxis(plot=plot, dimension=1)
     return plot
Exemple #2
0
 def make_downloads_plot(self, source):
     xdr = DataRange1d(sources=[source.columns("dates")])
     ydr = DataRange1d(sources=[source.columns("downloads")])
     title = "%s downloads" % self.modelform.installer
     plot = Plot(title=title,
                 data_sources=[source],
                 x_range=xdr,
                 y_range=ydr,
                 width=600,
                 height=400)
     line = Line(x="dates", y="downloads", line_color="blue")
     line_glyph = Glyph(data_source=source,
                        xdata_range=xdr,
                        ydata_range=ydr,
                        glyph=line)
     plot.renderers.append(line_glyph)
     circle = Circle(x="dates", y="downloads", fill_color="red")
     circle_glyph = Glyph(data_source=source,
                          xdata_range=xdr,
                          ydata_range=ydr,
                          glyph=circle)
     plot.renderers.append(circle_glyph)
     hover = HoverTool(plot=plot, tooltips=dict(downloads="@downloads"))
     plot.tools.append(hover)
     xformatter = DatetimeTickFormatter(formats=dict(months=["%b %Y"]))
     yformatter = BasicTickFormatter(precision=None, use_scientific=False)
     xaxis = DatetimeAxis(plot=plot, dimension=0, formatter=xformatter)
     yaxis = LinearAxis(plot=plot, dimension=1, formatter=yformatter)
     xgrid = Grid(plot=plot, dimension=0, axis=xaxis)
     ygrid = Grid(plot=plot, dimension=1, axis=yaxis)
     return plot
Exemple #3
0
def trail_map(data):
    lon = (min(data.lon) + max(data.lon))/2
    lat = (min(data.lat) + max(data.lat))/2

    map_options = GMapOptions(lng=lon, lat=lat, zoom=13)
    plot = GMapPlot(title="%s - Trail Map" % title, map_options=map_options, plot_width=800, plot_height=800)

    xaxis = LinearAxis()
    plot.add_layout(xaxis, 'below')

    yaxis = LinearAxis()
    plot.add_layout(yaxis, 'left')

    xgrid = Grid(plot=plot, dimension=0, ticker=xaxis.ticker, grid_line_dash="dashed", grid_line_color="gray")
    ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker, grid_line_dash="dashed", grid_line_color="gray")
    plot.renderers.extend([xgrid, ygrid])

    hover = HoverTool(tooltips=dict(distance="@dist"))
    plot.add_tools(hover, PanTool(), WheelZoomTool(), ResetTool(), BoxSelectTool())

    line_source = ColumnDataSource(dict(x=data.lon, y=data.lat, dist=data.dist))

    line = Line(x="x", y="y", line_color="blue", line_width=2)
    plot.add_glyph(line_source, line)

    plot.x_range = DataRange1d(sources=[line_source.columns("x")])
    plot.y_range = DataRange1d(sources=[line_source.columns("y")])

    return plot
Exemple #4
0
def make_plot():
    source = ColumnDataSource(
        dict(
            dates=[date(2014, 3, i) for i in [1, 2, 3, 4, 5]],
            downloads=[100, 27, 54, 64, 75],
        ))
    xdr = DataRange1d(sources=[source.columns("dates")])
    ydr = DataRange1d(sources=[source.columns("downloads")])
    plot = Plot(title="Product downloads",
                data_sources=[source],
                x_range=xdr,
                y_range=ydr,
                width=400,
                height=400)
    line = Line(x="dates", y="downloads", line_color="blue")
    line_glyph = Glyph(data_source=source,
                       xdata_range=xdr,
                       ydata_range=ydr,
                       glyph=line)
    plot.renderers.append(line_glyph)
    circle = Circle(x="dates", y="downloads", fill_color="red")
    circle_glyph = Glyph(data_source=source,
                         xdata_range=xdr,
                         ydata_range=ydr,
                         glyph=circle)
    plot.renderers.append(circle_glyph)
    hover = HoverTool(plot=plot, tooltips=dict(downloads="@downloads"))
    plot.tools.append(hover)
    xaxis = DatetimeAxis(plot=plot, dimension=0)
    yaxis = LinearAxis(plot=plot, dimension=1)
    xgrid = Grid(plot=plot, dimension=0, axis=xaxis)
    ygrid = Grid(plot=plot, dimension=1, axis=yaxis)
    return plot, source
Exemple #5
0
def make_plot():
    xdr = DataRange1d(sources=[source.columns("dates")])
    ydr = DataRange1d(sources=[source.columns("downloads")])

    plot = Plot(title="Product downloads",
                x_range=xdr,
                y_range=ydr,
                plot_width=400,
                plot_height=400)

    line = Line(x="dates", y="downloads", line_color="blue")
    plot.add_glyph(source, line)

    circle = Circle(x="dates", y="downloads", fill_color="red")
    plot.add_glyph(source, circle)

    xaxis = DatetimeAxis()
    plot.add_layout(xaxis, 'below')

    yaxis = LinearAxis()
    plot.add_layout(yaxis, 'left')

    plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
    plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))

    plot.add_tools(HoverTool(tooltips=dict(downloads="@downloads")))

    return plot, source