def _create_plot_component(): red = util.Color(255, 0, 0, 255) green = util.Color(0, 255, 0, 255) blue = util.Color(0, 0, 255, 255) purple = util.Color(125, 0, 255, 255) white = util.Color(255, 255, 255, 255) black = util.Color(0, 0, 0, 255) clear = util.Color(0, 0, 0, 0) with Timer("Loeading") as arTimer: #glyphs = npg.load_csv("../data/circlepoints.csv", 1, 2, 3, 4) #glyphs = npg.load_hdf("../data/CensusTracts.hdf5", "__data__", "LAT", "LON") glyphs = npg.load_hdf("../data/tweets-subset.hdf", "test", "longitude", "latitude", vc="lang_primary") screen = (800, 600) ivt = util.zoom_fit(screen, glyphs.bounds()) with Timer("Abstract-Render") as arTimer: image = core.render( glyphs, infos.encode(["Arabic", "English", "Turkish", "Russian"]), npg.PointCountCategories(), npg.Spread(2) + categories.HDAlpha( [red, blue, green, purple, black], alphamin=.3, log=True), screen, ivt) # image = core.render(glyphs, # infos.valAt(4,0), # npg.PointCount(), # npg.Spread(1) + numeric.BinarySegment(white, black, 1), # screen, # ivt) # Create a plot data object and give it this data pd = ArrayPlotData() pd.set_data("imagedata", image) # Create the plot plot = Plot(pd) img_plot = plot.img_plot("imagedata")[0] # Tweak some of the plot properties plot.title = "Abstract Rendering" plot.padding = 50 return plot
def _create_plot_component(): red = util.Color(255,0,0,255) green = util.Color(0,255,0,255) blue = util.Color(0,0,255,255) purple = util.Color(125,0,255,255) white = util.Color(255,255,255,255) black = util.Color(0,0,0,255) clear = util.Color(0,0,0,0) with Timer("Loeading") as arTimer: #glyphs = npg.load_csv("../data/circlepoints.csv", 1, 2, 3, 4) glyphs = npg.load_hdf("../data/CensusTracts.hdf5", "__data__", "LAT", "LON") #glyphs = npg.load_hdf("../data/tweets-subset.hdf", "test", # "longitude", "latitude", vc="lang_primary") screen = (800,600) ivt = util.zoom_fit(screen,glyphs.bounds()) with Timer("Abstract-Render") as arTimer: image = core.render(glyphs, infos.encode(["Arabic","English","Turkish","Russian"]), npg.PointCountCategories(), npg.Spread(2) + categories.HDAlpha([red, blue, green, purple, black], alphamin=.3, log=True), screen, ivt) # image = core.render(glyphs, # infos.valAt(4,0), # npg.PointCount(), # npg.Spread(1) + numeric.BinarySegment(white, black, 1), # screen, # ivt) # Create a plot data object and give it this data pd = ArrayPlotData() pd.set_data("imagedata", image) # Create the plot plot = Plot(pd) img_plot = plot.img_plot("imagedata")[0] # Tweak some of the plot properties plot.title = "Abstract Rendering" plot.padding = 50 return plot
def _create_plot_component(): red = util.Color(255,0,0,255) green = util.Color(0,255,0,255) blue = util.Color(0,0,255,255) white = util.Color(255,255,255,255) black = util.Color(0,0,0,255) shape = glyphset.ShapeCodes.POINT #glyphs = glyphset.load_csv("../data/checkerboard.csv", 2, 0, 1, 3,1,1, shape) #glyphs = glyphset.load_csv("../data/circlepoints.csv", 1, 2, 3, 4,.1,.1, shape) #glyphs = glyphset.load_csv("../data/sourceforge.csv", 1, 1, 2, -1,.1,.1, shape) glyphs = glyphset.load_hdf("../data/CensusTracts.hdf5", "__data__", "LON", "LAT", None, .1, .1, shape) #glyphs = glyphset.load_hdf("../data/tweets-subset.hdf", "test", "longitude", "latitude", None, .1, .1, shape) screen = (800,600) ivt = util.zoom_fit(screen,glyphs.bounds()) with Timer("Abstract-Render") as arTimer: # image = core.render(glyphs, # infos.val(), # categories.CountCategories(), # categories.HDAlpha([red, blue]), # screen, # ivt) image = core.render(glyphs, infos.valAt(4,0), numeric.Count(), numeric.BinarySegment(white, black, 1), screen, ivt) print("screen x image -- {0} x {1}".format(screen, image.shape)) # Create a plot data object and give it this data pd = ArrayPlotData() pd.set_data("imagedata", image) # Create the plot plot = Plot(pd) img_plot = plot.img_plot("imagedata")[0] # Tweak some of the plot properties plot.title = "Abstract Rendering" plot.padding = 50 return plot
def _create_plot_component(): red = util.Color(255, 0, 0, 255) green = util.Color(0, 255, 0, 255) blue = util.Color(0, 0, 255, 255) purple = util.Color(125, 0, 255, 255) white = util.Color(255, 255, 255, 255) black = util.Color(0, 0, 0, 255) shape = glyphset.ShapeCodes.RECT glyphs = blzg.load_csv( "../data/circlepoints.csv", "x", "y", "series", schema="{r:float32, theta:float32, x:float32, y:float32, series:int32}" ) screen = (800, 600) ivt = util.zoom_fit(screen, glyphs.bounds()) with Timer("Abstract-Render") as arTimer: image = core.render( glyphs, infos.val(), blzg.CountCategories("int32"), categories.HDAlpha([red, blue, green, purple, black]), screen, ivt) # image = core.render(glyphs, # infos.valAt(4,0), # blzg.Count(), # numeric.BinarySegment(white, black, 1), # screen, # ivt) # Create a plot data object and give it this data pd = ArrayPlotData() pd.set_data("imagedata", image) # Create the plot plot = Plot(pd) img_plot = plot.img_plot("imagedata")[0] # Tweak some of the plot properties plot.title = "Abstract Rendering" plot.padding = 50 return plot
def _create_plot_component(): red = util.Color(255,0,0,255) green = util.Color(0,255,0,255) blue = util.Color(0,0,255,255) purple = util.Color(125,0,255,255) white = util.Color(255,255,255,255) black = util.Color(0,0,0,255) shape = glyphset.ShapeCodes.RECT glyphs = blzg.load_csv("../data/circlepoints.csv", "x", "y", "series", schema="{r:float32, theta:float32, x:float32, y:float32, series:int32}") screen = (800,600) ivt = util.zoom_fit(screen,glyphs.bounds()) with Timer("Abstract-Render") as arTimer: image = core.render(glyphs, infos.val(), blzg.CountCategories("int32"), categories.HDAlpha([red, blue, green, purple, black]), screen, ivt) # image = core.render(glyphs, # infos.valAt(4,0), # blzg.Count(), # numeric.BinarySegment(white, black, 1), # screen, # ivt) # Create a plot data object and give it this data pd = ArrayPlotData() pd.set_data("imagedata", image) # Create the plot plot = Plot(pd) img_plot = plot.img_plot("imagedata")[0] # Tweak some of the plot properties plot.title = "Abstract Rendering" plot.padding = 50 return plot
def downsample(data, transform, plot_state): screen_size = [span(plot_state['screen_x']), span(plot_state['screen_y'])] scale_x = span(plot_state['data_x'])/float(span(plot_state['screen_x'])) scale_y = span(plot_state['data_y'])/float(span(plot_state['screen_y'])) #How big would a full plot of the data be at the current resolution? plot_size = [screen_size[0] / scale_x, screen_size[1] / scale_y] glyphspec = transform['glyphspec'] xcol = glyphspec['x']['field'] ycol = glyphspec['y']['field'] size = glyphspec['size']['default'] ##TODO: Will not work for data-derived sizes... ###Translate the resample paramteres to server-side rendering.... ###TODO: Should probably handle this type-based-unpacking server_backend so downsamples get a consistent view of the data if type(data) is dict: xcol = data[xcol] ycol = data[ycol] else: table = data.select(columns=[xcol, ycol]) xcol = table[xcol] ycol = table[ycol] shaper = _shaper(glyphspec['type'], size) glyphs = glyphset.Glyphset([xcol, ycol], ar.EmptyList(), shaper, colMajor=True) bounds = glyphs.bounds() ivt = ar.zoom_fit(plot_size, bounds, balanced=False) image = ar.render(glyphs, transform['info'].reify(), transform['agg'].reify(), transform['shader'].reify(), plot_size, ivt) return {'image': [image], 'x': [0], 'y': [0], 'dw': [image.shape[0]], 'dh': [image.shape[1]], }