def test_replot_property_transfer(self): ar_downsample._loadAR() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource( expr={'op': 'Field', 'args': [':leaf', 'bivariate']} ) plot_width = 612 plot_height = 408 plot_title = "Test title" plot = figure(plot_width=plot_width, plot_height=plot_height, title=plot_title) plot.square('A', 'B', source=source) ar_plot = ar_downsample.replot(plot) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width not transfered") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height not transfered") self.assertEquals(ar_plot.title, plot_title, "Plot title not transfered") plot_width = 612 plot_height = 408 plot_title = "Test title" ar_plot = ar_downsample.replot(plot, title=plot_title, plot_width=plot_width, plot_height=plot_height) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width override failed") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height override failed") self.assertEquals(ar_plot.title, plot_title, "Plot title override failed")
def test_replot_property_transfer(self): self.assertIsNotNone(self.bokeh_server, "Server failed to start, cannot tests") ar_downsample._loadAR() output_server("Census") source = ServerDataSource(data_url="fn://bivariate", owner_username="******") plot_width = 612 plot_height = 408 plot_title = "Test title" plot = figure(lot_width=plot_width, plot_height=plot_height, title=plot_title) plot.square('A', 'B', source=source) ar_plot = ar_downsample.replot(plot) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width not transfered") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height not transfered") self.assertEquals(ar_plot.title, plot_title, "Plot title not transfered") plot_width = 612 plot_height = 408 plot_title = "Test title" ar_plot = ar_downsample.replot(plot, title=plot_title, plot_width=plot_width, plot_height=plot_height) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width override failed") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height override failed") self.assertEquals(ar_plot.title, plot_title, "Plot title override failed")
def test_replot_result_type(self): ar_downsample._loadAR() source = ServerDataSource(data_url="fn://bivariate", owner_username="******") plot = square('A', 'B', source=source) expected = { "image": "Image", "image_rgb": "ImageRGBA", "multi_line": "MultiLine" } shaders = dict() for name in dir(ar_downsample): item = getattr(ar_downsample, name) if isinstance(item, ar_downsample.Shader): shaders[item] = item.out for shader_class in shaders: shader = shader_class() rslt = ar_downsample.replot(plot, shader=shader) self.assertEquals( expected[shader.out], self._glyphspec(rslt)['type'], "Error with {0}. Expected {1}, recieved {2}".format( str(shader_class), expected[shader.out], self._glyphspec(rslt)))
def test_replot_result_type(self): ar_downsample._loadAR() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource( expr={'op': 'Field', 'args': [':leaf', 'bivariate']} ) plot = figure() plot.square('A', 'B', source=source) expected = {"image": "Image", "image_rgb": "ImageRGBA", "multi_line": "MultiLine"} shaders = dict() for name in dir(ar_downsample): item = getattr(ar_downsample, name) if isinstance(item, ar_downsample.Shader): shaders[item] = item.out for shader_class in shaders: shader = shader_class() rslt = ar_downsample.replot(plot, shader=shader) self.assertEquals(expected[shader.out], self._glyphspec(rslt)['type'], "Error with {0}. Expected {1}, recieved {2}" .format(str(shader_class), expected[shader.out], self._glyphspec(rslt)))
def test_replot_result_type(self): ar_downsample._loadAR() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource(expr={ 'op': 'Field', 'args': [':leaf', 'bivariate'] }) plot = figure() plot.square('A', 'B', source=source) expected = { "image": "Image", "image_rgb": "ImageRGBA", "multi_line": "MultiLine" } shaders = dict() for name in dir(ar_downsample): item = getattr(ar_downsample, name) if isinstance(item, ar_downsample.Shader): shaders[item] = item.out for shader_class in shaders: shader = shader_class() rslt = ar_downsample.replot(plot, shader=shader) self.assertEquals( expected[shader.out], self._glyphspec(rslt)['type'], "Error with {0}. Expected {1}, recieved {2}".format( str(shader_class), expected[shader.out], self._glyphspec(rslt)))
def test_replot_property_transfer(self): ar_downsample._loadAR() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource(expr={ 'op': 'Field', 'args': [':leaf', 'bivariate'] }) plot_width = 612 plot_height = 408 plot_title = "Test title" plot = figure(plot_width=plot_width, plot_height=plot_height, title=plot_title) plot.square('A', 'B', source=source) ar_plot = ar_downsample.replot(plot) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width not transfered") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height not transfered") self.assertEquals(ar_plot.title, plot_title, "Plot title not transfered") plot_width = 612 plot_height = 408 plot_title = "Test title" ar_plot = ar_downsample.replot(plot, title=plot_title, plot_width=plot_width, plot_height=plot_height) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width override failed") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height override failed") self.assertEquals(ar_plot.title, plot_title, "Plot title override failed")
def test_replot_property_transfer(self): self.assertIsNotNone(self.bokeh_server, "Server failed to start, cannot tests") ar_downsample._loadAR() output_server("Census") source = ServerDataSource(data_url="fn://bivariate", owner_username="******") plot_width = 612 plot_height = 408 plot_title = "Test title" plot = square('A', 'B', source=source, plot_width=plot_width, plot_height=plot_height, title=plot_title) ar_plot = ar_downsample.replot(plot) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width not transfered") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height not transfered") self.assertEquals(ar_plot.title, plot_title, "Plot title not transfered") plot_width = 612 plot_height = 408 plot_title = "Test title" ar_plot = ar_downsample.replot(plot, title=plot_title, plot_width=plot_width, plot_height=plot_height) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width override failed") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height override failed") self.assertEquals(ar_plot.title, plot_title, "Plot title override failed")
def test_replot_result_type(self): ar_downsample._loadAR() source = ServerDataSource(data_url="fn://bivariate", owner_username="******") plot = square('A', 'B', source=source) expected = {"image": "Image", "image_rgb": "ImageRGBA", "multi_line": "MultiLine"} shaders = dict() for name in dir(ar_downsample): item = getattr(ar_downsample, name) if hasattr(item, "out"): shaders[item] = getattr(item, "out") for shader_class in shaders: shader = shader_class() rslt = ar_downsample.replot(plot, shader=shader) self.assertEquals(expected[shader.out], self._glyphspec(rslt)['type'], "Error with {0}. Expected {1}, recieved {2}" .format(str(shader_class), expected[shader.out], self._glyphspec(rslt)))
def test_replot_remove(self): self.assertIsNotNone(self.bokeh_server, "Server failed to start, cannot tests") ar_downsample._loadAR() output_server("Census") source = ServerDataSource(data_url="fn://bivariate", owner_username="******") plot = square('A', 'B', source=source) ar_downsample.replot(plot, remove_original=False) self.assertTrue(plot in curdoc().context.children, "Not retained") ar_downsample.replot(plot, remove_original=True) self.assertTrue(plot not in curdoc().context.children, "Not removed") try: ar_downsample.replot(plot, remove_original=True) except: self.assertTrue(False, "Error reploting plot not in curdoc")
def test_replot_remove(self): self.assertIsNotNone(self.bokeh_server, "Server failed to start, cannot tests") ar_downsample._loadAR() output_server("Census") source = ServerDataSource(data_url="fn://bivariate", owner_username="******") plot = figure() plot.square('A', 'B', source=source) ar_downsample.replot(plot, remove_original=False) self.assertTrue(plot in curdoc().context.children, "Not retained") ar_downsample.replot(plot, remove_original=True) self.assertTrue(plot not in curdoc().context.children, "Not removed") try: ar_downsample.replot(plot, remove_original=True) except: self.assertTrue(False, "Error reploting plot not in curdoc")
def test_replot_remove(self): ar_downsample._loadAR() reset_output() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource( expr={'op': 'Field', 'args': [':leaf', 'bivariate']} ) plot = figure() plot.square('A', 'B', source=source) ar_downsample.replot(plot, remove_original=False) self.assertTrue(plot in curdoc().context.children, "Not retained") ar_downsample.replot(plot, remove_original=True) self.assertTrue(plot not in curdoc().context.children, "Not removed") try: ar_downsample.replot(plot, remove_original=True) except: self.assertTrue(False, "Error reploting plot not in curdoc")
def test_replot_remove(self): ar_downsample._loadAR() reset_output() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource(expr={ 'op': 'Field', 'args': [':leaf', 'bivariate'] }) plot = figure() plot.square('A', 'B', source=source) ar_downsample.replot(plot, remove_original=False) self.assertTrue(plot in curdoc().context.children, "Not retained") ar_downsample.replot(plot, remove_original=True) self.assertTrue(plot not in curdoc().context.children, "Not removed") try: ar_downsample.replot(plot, remove_original=True) except: self.assertTrue(False, "Error reploting plot not in curdoc")
source.from_blaze(d.gauss, local=True) plot = figure() plot.square('oneA', 'oneB', color='#FF00FF', source=source) #Server-side colored heatmap arplot = ar.heatmap(plot, spread=3, transform=None, title="Server-rendered, uncorrected") arplot = ar.heatmap(plot, spread=3, transform="Log", title="Server-rendered, log transformed") arplot = ar.heatmap(plot, spread=3, title="Server-rendered, perceptually corrected") ar.replot(plot, agg=ar.Count(), info=ar.Const(val=1), shader=ar.Spread(factor=3) + ar.Cuberoot() + ar.InterpolateColor(low=(255,200,200), high=(255,0,0)), points=True, title="Manually process: perceptually corrected", reserve_val=0) # Client-side colored heatmap # I think this has been broken for a while? # ar.heatmap(plot, spread=3, client_color=True, palette="Reds9", title="Client-colored") # 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.contours(plot, palette=colors, title="ISO Contours") # # Multiple categories source = ServerDataSource()
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 # #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"])
from bokeh.plotting import square, output_server, show from bokeh.objects import ServerDataSource import bokeh.transforms.ar_downsample as ar output_server("Census") # 2010 US Census tracts source = ServerDataSource(data_url="/defaultuser/CensusTracts.hdf5", owner_username="******") plot = square( 'LON', 'LAT', source=source, plot_width=600, plot_height=400, title="Census Tracts") ar.replot(plot, palette=["Reds-9"], reserve_val=0, points=True) ar.replot(plot, shader=ar.Cuberoot() + ar.InterpolateColor(low=(255, 200, 200)), points=True, title="Census Tracts (Server Colors)") colors = ["#C6DBEF", "#9ECAE1", "#6BAED6", "#4292C6", "#2171B5", "#08519C", "#08306B"] ar.replot(plot, shader=ar.Cuberoot() + ar.Spread(factor=2) + ar.Contour(levels=len(colors)), line_color=colors, points=True, title="Census (Contours)") show()