def jobtype_builder(): jtypes = ["Half Time", "Full Time", "Hourly", "Temporary"] xdr = FactorRange(factors=jtypes) ydr = DataRange1d(sources=[source_jobtype.columns("data_range")]) plot = Plot(title="Job Type", data_sources=[source_jobtype], x_range=xdr, y_range=ydr, plot_width=760, plot_height=500) xaxis = CategoricalAxis(plot=plot, dimension=0, major_label_orientation=pi / 4.0) yaxis = LinearAxis(plot=plot, dimension=1) yaxis.major_tick_in = 0 ygrid = Grid(plot=plot, dimension=1, axis=yaxis) quad = Rect(x="jobtypes", y="jobtype_half", height="count", width=0.9, fill_color="#33A6A4") bars = Glyph(data_source=source_jobtype, xdata_range=xdr, ydata_range=ydr, glyph=quad) plot.renderers.append(bars) plot.background_fill = '#686975' return plot
def weekday_builder(): dow = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ] xdr = FactorRange(factors=dow) ydr = DataRange1d(sources=[source_dow.columns("data_range")]) plot = Plot(title="Weekday of Job Posting", data_sources=[source_dow], x_range=xdr, y_range=ydr, plot_width=760, plot_height=500) xaxis = CategoricalAxis(plot=plot, dimension=0, major_label_orientation=pi / 4.0) yaxis = LinearAxis(plot=plot, dimension=1) yaxis.major_tick_in = 0 ygrid = Grid(plot=plot, dimension=1, axis=yaxis) quad = Rect(x="weekday", y="weekday_half", height="count", width=0.9, fill_color="#D9301A") bars = Glyph(data_source=source_dow, xdata_range=xdr, ydata_range=ydr, glyph=quad) plot.renderers.append(bars) plot.background_fill = '#686975' return plot
def job_loc_plot_builder(): xdr = FactorRange(factors=countries) ydr = DataRange1d(sources=[source_country.columns("data_range")]) plot = Plot(title="Postings by Job Location (Country)", data_sources=[source_country], x_range=xdr, y_range=ydr, plot_width=760, plot_height=500) xaxis = CategoricalAxis(plot=plot, dimension=0, major_label_orientation=pi / 4.0) yaxis = LinearAxis(plot=plot, dimension=1) yaxis.major_tick_in = 0 ygrid = Grid(plot=plot, dimension=1, axis=yaxis) quad = Rect(x="country", y="count_half", height="count", width=0.9, fill_color="#483D8B") bars = Glyph(data_source=source_country, xdata_range=xdr, ydata_range=ydr, glyph=quad) plot.renderers.append(bars) plot.background_fill = '#333333' return plot
def jobtype_builder(): jtypes = ["Half Time", "Full Time", "Hourly", "Temporary"] xdr = FactorRange(factors=jtypes) ydr = DataRange1d(sources=[source_jobtype.columns("data_range")]) plot = Plot(title="Job Type", data_sources=[source_jobtype], x_range=xdr, y_range=ydr, plot_width=760, plot_height=500) xaxis = CategoricalAxis(plot=plot, dimension=0, major_label_orientation=pi/4.0) yaxis = LinearAxis(plot=plot, dimension=1) yaxis.major_tick_in = 0 ygrid = Grid(plot=plot, dimension=1, axis=yaxis) quad = Rect(x="jobtypes", y="jobtype_half", height="count", width=0.9, fill_color="#33A6A4") bars = Glyph(data_source=source_jobtype, xdata_range=xdr, ydata_range=ydr, glyph=quad) plot.renderers.append(bars) plot.background_fill = '#686975' return plot
def weekday_builder(): dow = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] xdr = FactorRange(factors=dow) ydr = DataRange1d(sources=[source_dow.columns("data_range")]) plot = Plot(title="Weekday of Job Posting", data_sources=[source_dow], x_range=xdr, y_range=ydr, plot_width=760, plot_height=500) xaxis = CategoricalAxis(plot=plot, dimension=0, major_label_orientation=pi/4.0) yaxis = LinearAxis(plot=plot, dimension=1) yaxis.major_tick_in = 0 ygrid = Grid(plot=plot, dimension=1, axis=yaxis) quad = Rect(x="weekday", y="weekday_half", height="count", width=0.9, fill_color="#D9301A") bars = Glyph(data_source=source_dow, xdata_range=xdr, ydata_range=ydr, glyph=quad) plot.renderers.append(bars) plot.background_fill = '#686975' return plot
def job_loc_plot_builder(): xdr = FactorRange(factors=countries) ydr = DataRange1d(sources=[source_country.columns("data_range")]) plot = Plot(title="Postings by Job Location (Country)", data_sources=[source_country], x_range=xdr, y_range=ydr, plot_width=760, plot_height=500) xaxis = CategoricalAxis(plot=plot, dimension=0, major_label_orientation=pi/4.0) yaxis = LinearAxis(plot=plot, dimension=1) yaxis.major_tick_in = 0 ygrid = Grid(plot=plot, dimension=1, axis=yaxis) quad = Rect(x="country", y="count_half", height="count", width=0.9, fill_color="#483D8B") bars = Glyph(data_source=source_country, xdata_range=xdr, ydata_range=ydr, glyph=quad) plot.renderers.append(bars) plot.background_fill = '#333333' return plot
from bokeh.models import Plot from bokeh.models import Range1d from bokeh.models import WheelZoomTool, PanTool from bokeh.models import ImageSource, WMTSTileSource # create plot object title = 'Dynamic Map: National Land Cover Dataset' x_range = Range1d(start=-15473429, end=2108550) y_range = Range1d(start=-6315661, end=7264686) p = Plot(x_range=x_range, y_range=y_range, plot_height=700, plot_width=700, title=title) p.background_fill = "black" p.add_tools(WheelZoomTool(), PanTool()) # add base layer tile_options = {} tile_options['url'] = 'http://tile.stamen.com/toner/{Z}/{X}/{Y}.png' tile_source = WMTSTileSource(**tile_options) p.add_tile(tile_source) # add dynamic data layer # National Land Cover Dataset (http://www.mrlc.gov/nlcd2011.php) service_url = 'http://raster.nationalmap.gov/arcgis/rest/services/LandCover/USGS_EROS_LandCover_NLCD/MapServer/export?' service_url += 'bbox={XMIN},{YMIN},{XMAX},{YMAX}&bboxSR=102100&size={HEIGHT}%2C{WIDTH}&imageSR=102100&format=png32&transparent=true&f=image' image_source_options = {} image_source_options['url'] = service_url image_source = ImageSource(**image_source_options)
from bokeh.browserlib import view from bokeh.document import Document from bokeh.embed import file_html from bokeh.resources import INLINE from bokeh.models import Plot from bokeh.models import Range1d from bokeh.models import WheelZoomTool, PanTool from bokeh.models import ImageSource, WMTSTileSource # create plot object title = 'Dynamic Map: National Land Cover Dataset' x_range = Range1d(start=-15473429, end=2108550) y_range = Range1d(start=-6315661, end=7264686) p = Plot(x_range=x_range, y_range=y_range, plot_height=700, plot_width=700, title=title) p.background_fill = "black" p.add_tools(WheelZoomTool(), PanTool()) # add base layer tile_options = {} tile_options['url'] = 'http://tile.stamen.com/toner/{Z}/{X}/{Y}.png' tile_source = WMTSTileSource(**tile_options) p.add_tile(tile_source) # add dynamic data layer # National Land Cover Dataset (http://www.mrlc.gov/nlcd2011.php) service_url = 'http://raster.nationalmap.gov/arcgis/rest/services/LandCover/USGS_EROS_LandCover_NLCD/MapServer/export?' service_url += 'bbox={XMIN},{YMIN},{XMAX},{YMAX}&bboxSR=102100&size={HEIGHT}%2C{WIDTH}&imageSR=102100&format=png32&transparent=true&f=image' image_source_options = {} image_source_options['url'] = service_url image_source = ImageSource(**image_source_options)