Ejemplo n.º 1
0
def plot_adj(adj):
    N, _ = adj.shape
    plt.output_file("adjacency.html", title="Adjacency")
    TOOLS="pan,wheel_zoom,box_zoom,reset,click,previewsave"
    plt.figure(plot_width=N+100, plot_height=N+100, tools=TOOLS)
    plt.image(image=[adj], x =[0], y=[0], dw=[N], dh=[N], 
      x_range=[0, N], y_range=[0, N],palette=["YlGnBu-3"])
    plt.show()
Ejemplo n.º 2
0
def plot_adj(adj, sparcity):
    N, _ = adj.shape
    TOOLS="pan,wheel_zoom,box_zoom,reset,click,previewsave"
    plt.figure(plot_width=N+100, plot_height=N+100, tools=TOOLS)
    plt.image(image=[adj], x =[0], y=[0], dw=[N], dh=[N], 
              x_range=[0, N], y_range=[0, N],
              palette=["Blues-3"],
              title="Adjacency of top %d nodes (%.2f%% sparcity)" % (N, sparcity),
              x_axis_type=None, y_axis_type=None)
    return plt.curplot()
Ejemplo n.º 3
0
def build_plot(slice=None):
    if not slice:
        slice = data.shape[0] / 2
    sliced = data[slice, :, :].T
    p = image(image=[sliced],
              x=list(range(0, sliced.shape[0])),
              y=list(range(0, sliced.shape[1])),
              dw=[sliced.shape[1]],
              dh=[sliced.shape[0]],
              palette=['Greys-9'],
              dilate=True)
    return p.create_html_snippet(server=True)
Ejemplo n.º 4
0
def build_plot(slice=None):
    if not slice:
        slice = data.shape[0] / 2
    sliced = data[slice, :, :].T
    p = image(image=[sliced],
          x=list(range(0, sliced.shape[0])),
          y=list(range(0, sliced.shape[1])),
          dw=[sliced.shape[1]],
          dh=[sliced.shape[0]],
          palette=['Greys-9'],
          dilate=True)
    return p.create_html_snippet(server=True)
Ejemplo n.º 5
0
import numpy as np
from bokeh.plotting import square, output_server, image, show
from bokeh.objects import ServerDataSource

import bokeh.transforms.ar_downsample as ar
#from bokeh.transforms import line_downsample


output_server("Census")
#2010 US Census tracts
source = ServerDataSource(data_url="/defaultuser/CensusTracts.hdf5", owner_username="******")
plot = square( 'LON','LAT',source=source)
heatmap = ar.source(plot, palette=["Reds-9"], points=True)
image(source=heatmap, title="Census Tracts", reserve_val=0, plot_width=600, plot_height=400, **ar.mapping(heatmap))

show()
Ejemplo n.º 6
0
import numpy as np
from bokeh.plotting import square, output_server, image, show
from bokeh.objects import ServerDataSource

import bokeh.transforms.ar_downsample as ar
#from bokeh.transforms import line_downsample


output_server("abstractrender")
source = ServerDataSource(data_url="fn://gauss", owner_username="******")
plot = square('oneA', 'oneB', color='#FF00FF', source=source)


# Simple heat-map: bin the counts ('tis the default configuration....)
heatmap =ar.source(plot, palette=["Reds-9"])
image(source=heatmap, title="Heatmap", reserve_val=0, **ar.mapping(heatmap))

#Perceptually corrected heat-map.  Cube-root then bin
percepmap = ar.source(plot, shader=ar.Cuberoot(), palette=["Reds-9"])
image(source=percepmap, title="Perceptually corrected", reserve_val=0, **ar.mapping(percepmap))


# Contours come in the same framework, but since the results of the shader are lines you use a different plotting function...
colors = ["#C6DBEF", "#9ECAE1", "#6BAED6", "#4292C6", "#2171B5", "#08519C", "#08306B"]
ar.replot(plot, title="ISO Contours", shader=ar.Contour(levels=len(colors)), line_color=colors)

#"""
#In order to run the 'stocks' example, you have to execute
#./bokeh-server -D remotedata
#
#The remote data directory in the bokeh checkout has the sample data for this example
Ejemplo n.º 7
0
    def create(cls):
        gbounds = cls.gbounds
        xmin, xmax, ymin, ymax = gbounds
        app = cls()
        data = ARDataSource(
            data_url="/bokeh/taxidata/pickup/",
            data=dict(
                x=[0], y=[0], dw=[xmax-xmin], dh=[ymax-ymin], palette=["Greys-256"]
            )
        )
        app.pickup_ar_plot_source = data
        plot = image(source=data,
                     image="image",
                     x="x",
                     y="y",
                     dw="dw",
                     dh="dh",
                     plot_width=400,
                     plot_height=400,
                     palette='palette',
                     x_range=[xmin, xmax], y_range=[ymin, ymax],
                     tools="pan,wheel_zoom,box_zoom,select,reset",
                     title='pickup'
        )
        plot.title_text_font='12pt'
        app.pickup_plot = plot
        app.pickup_raw_plot_source = plot.select({'type' : ColumnDataSource})[0]

        data = ARDataSource(
            data_url="/bokeh/taxidatavsregular/pickup/",
            data=dict(
                x=[0], y=[0], dw=[xmax-xmin], dh=[ymax-ymin], palette=["Greys-256"]
            )
        )
        app.pickup_comparison_ar_plot_source = data
        plot = image(source=data,
                     image="image",
                     x="x",
                     y="y",
                     dw="dw",
                     dh="dh",
                     plot_width=400,
                     plot_height=400,
                     palette='palette',
                     x_range=[xmin, xmax], y_range=[ymin, ymax],
                     tools="pan,wheel_zoom,box_zoom,select,reset",
                     title='pickup comparison plot'
        )
        plot.title_text_font='12pt'
        app.pickup_comparison_plot = plot
        app.pickup_comparison_raw_plot_source = plot.select({'type' : ColumnDataSource})[0]
        data = ARDataSource(
            data_url="/bokeh/taxidatavsregular/dropoff/",
            data=dict(
                x=[0], y=[0], dw=[xmax-xmin], dh=[ymax-ymin], palette=["Greys-256"]
            )
        )
        app.dropoff_comparison_ar_plot_source = data
        plot = image(source=data,
                     image="image",
                     x="x",
                     y="y",
                     dw="dw",
                     dh="dh",
                     plot_width=400,
                     plot_height=400,
                     palette='palette',
                     x_range=[xmin, xmax], y_range=[ymin, ymax],
                     tools="pan,wheel_zoom,box_zoom,select,reset",
                     title='dropoff comparison plot'
        )
        plot.title_text_font='12pt'
        app.dropoff_comparison_plot = plot
        app.dropoff_comparison_raw_plot_source = plot.select({'type' : ColumnDataSource})[0]

        data = ARDataSource(
            data_url="/bokeh/taxidata/dropoff/",
            data=dict(
                x=[0], y=[0], dw=[xmax-xmin], dh=[ymax-ymin], palette=["Greys-256"]
            )
        )
        app.dropoff_ar_plot_source = data
        plot = image(source=data,
                     image="image",
                     plot_width=400,
                     plot_height=400,
                     x="x",
                     y="y",
                     dw="dw",
                     dh="dh",
                     palette='palette',
                     x_range=[xmin, xmax], y_range=[ymin, ymax],
                     tools="pan,wheel_zoom,box_zoom,reset,select,reset",
                     title='dropoff'
        )
        plot.title_text_font='12pt'
        app.dropoff_plot = plot
        app.dropoff_raw_plot_source = plot.select({'type' : ColumnDataSource})[0]
        app.make_trip_distance_histogram()
        app.make_trip_time_histogram()
        app.widgets = VBoxForm()
        app.day_of_week_selector = Select.create(
            options=["-----", 'Weekday', 'Friday/Saturday/Sunday', 'Saturday/Sunday'],
            name='Day Of Week'
        )
        app.date_slider = DateRangeSlider(value=(dt.datetime(2012, 1, 1),
                                                 dt.datetime(2013, 1, 28)),
                                          bounds=(dt.datetime(2012, 12, 31),
                                                  dt.datetime(2013, 1, 31)),
                                          step={'days' : 1},
                                          range=({'days' : 1},{'days':30}),
                                          name='period',
                                          title='period'
        )
        app.hour_selector = Select.create(options=["-----",
                                                   '8am-12pm',
                                                   '12pm-4pm',
                                                   '4pm-8pm',
                                                   '8pm-12am',
                                                   '12am-4am'],
                                          name='Hour of the Day'
        )
        title = Paragraph(text="NYC Taxi Cab Data", width=250, height=50)
        app.widgets.children=[title, app.date_slider,
                              Paragraph(width=250, height=10),
                              app.hour_selector,
                              app.day_of_week_selector,
                              Paragraph(width=250, height=10),
                              app.distance_histogram,
                              Paragraph(text="",
                                        width=250, height=50),
                              app.time_histogram]
        app.images = VBox()
        app.regular = HBox()
        app.filtered = HBox()
        app.regular.children = [app.pickup_plot, app.dropoff_plot]
        app.filtered.children = [app.pickup_comparison_plot,
                                  app.dropoff_comparison_plot]
        app.images.children = [app.regular]
        app.children = [app.widgets, app.images]
        return app
Ejemplo n.º 8
0
#aggregator = ar.source(ar.count(), ar.const(1), ar.touches())  ### Aggregator is incomplete without shader and glyphs.  Can add either to it
#shader = ar.Cuberoot()+ar.Interpolate(0,9) + ar.Floor()
#image(source=plot+aggregator+shader, palette=["reds-9"])   ###Implement aggregator.__radd__ to get a plot and .__add__ to get a shader


"""
In order to run the 'stocks' example, you have to execute
./bokeh-server -D remotedata

The remote data directory in the bokeh checkout has the sample data for this example

In addition, you must install ArrayManagement from this branch (soon to be master)
https://github.com/ContinuumIO/ArrayManagement
"""

#Stock-data plotting
#source = ServerDataSource(data_url="/defaultuser/AAPL.hdf5", owner_username="******")
#plot = square('volume','close',color='#FF00FF',source=source)
#percepmap = ar.source(plot, shader=ar.Cuberoot(), palette=["Reds-9"])
#image(source=percepmap, title="Perceptually corrected (Stocks)", reserve_val=0, **ar.mapping(percepmap))

#2010 US Census tracts
source = ServerDataSource(data_url="/defaultuser/CensusTracts.hdf5", owner_username="******")
plot = square( 'INTPTLONG','INTPTLAT',source=source)
heatmap = ar.source(plot, palette=["Reds-9"])
image(source=heatmap, title="Census Tracts", reserve_val=0, **ar.mapping(heatmap))

show()