Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create_colorbar(colormap):
colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range),
color_mapper=colormap,
orientation='v',
resizable='v',
width=30,
padding=20)
colorbar.tools.append(RangeSelection(component=colorbar))
colorbar.overlays.append(RangeSelectionOverlay(component=colorbar,
border_color="white",
alpha=0.8,
fill_color="lightgray"))
return colorbar
# Create the colorbar, handing in the appropriate range and colormap
colormap = my_plot.color_mapper
colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range),
color_mapper=colormap,
plot=my_plot,
orientation='v',
resizable='v',
width=30,
padding=20)
colorbar.padding_top = plot.padding_top
colorbar.padding_bottom = plot.padding_bottom
# create a range selection for the colorbar
range_selection = RangeSelection(component=colorbar)
colorbar.tools.append(range_selection)
colorbar.overlays.append(RangeSelectionOverlay(component=colorbar,
border_color="white",
alpha=0.8,
fill_color="lightgray"))
# we also want to the range selection to inform the cmap plot of
# the selection, so set that up as well
range_selection.listeners.append(my_plot)
# Create a container to position the plot and the colorbar side-by-side
container = HPlotContainer(use_backbuffer = True)
container.add(plot)
container.add(colorbar)
container.bgcolor = "lightgray"
#my_plot.set_value_selection((-1.3, 6.9))
colormap = self.my_plot.color_mapper
self.colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range),
color_mapper=colormap,
plot=self.my_plot,
orientation='v',
resizable='v',
width=30,
padding=20)
self.colorbar.padding_top = self.tplot.padding_top
self.colorbar.padding_bottom = self.tplot.padding_bottom
# create a range selection for the colorbar
self.range_selection = RangeSelection(component=self.colorbar)
self.colorbar.tools.append(self.range_selection)
self.colorbar.overlays.append(RangeSelectionOverlay(component=self.colorbar,
border_color="white",
alpha=0.8,
fill_color="lightgray"))
# we also want to the range selection to inform the cmap plot of
# the selection, so set that up as well
self.range_selection.listeners.append(self.my_plot)
# Create a container to position the plot and the colorbar side-by-side
container = HPlotContainer(use_backbuffer = True)
container.add(self.tplot)
container.add(self.colorbar)
container.bgcolor = "white"
return container
self.maintool = (fctool,None)
fctool.on_trait_change(self._add_feature_point,'mouse_clicked')
elif new == 'Range Select':
pl.tools[0].drag_button = 'right'
fplot = pl.plots['flux'][0]
#TODO:clean up these hacky bugfix techniques if possible
rstool = RangeSelectionBugfix(component=fplot,
left_button_selects=True,
enable_resize=False,
mapper=self.plot.x_mapper)
rstool.plot = fplot
rstool.component = pl
rsoverlay = RangeSelectionOverlay(component=fplot,
mapper=self.plot.x_mapper)
rsoverlay.plot = fplot
rsoverlay.component = pl
self.maintool = (rstool,rsoverlay)
rstool.on_trait_change(self._add_feature_range,'selection_completed')
elif new == 'Base Select':
pl.tools[0].drag_button = 'right'
slt = SingleLineTool(component=self.plot)
slt.component = self.plot
self.maintool = (slt,slt)
slt.on_trait_change(self._add_feature_base,'finished')
elif new == 'Click Delete':
pl.tools[0].drag_button = 'right'
fctool = FeatureClickTool(plot=self.plot)
self.maintool = (fctool,None)
def create_colorbar(colormap):
colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range),
color_mapper=colormap,
orientation='v',
resizable='v',
width=30,
padding=20)
colorbar.grid_visible = False
colorbar._axis.tick_visible = False
colorbar.tools.append(RangeSelection(component=colorbar))
colorbar.overlays.append(RangeSelectionOverlay(component=colorbar,
border_color="white",
alpha=0.8,
fill_color="lightgray"))
return colorbar
selection_type="range")
cmap_renderer.overlays.append(selection)
if self.thresh is not None:
cmap_renderer.color_data.metadata['selections']=self.thresh
cmap_renderer.color_data.metadata_changed={'selections':self.thresh}
# Create the colorbar, handing in the appropriate range and colormap
colormap=scatplot.color_mapper
colorbar = ColorBar(index_mapper=LinearMapper(range=DataRange1D(low = 0.0,
high = 1.0)),
orientation='v',
resizable='v',
width=30,
padding=20)
colorbar_selection=RangeSelection(component=colorbar)
colorbar.tools.append(colorbar_selection)
ovr=colorbar.overlays.append(RangeSelectionOverlay(component=colorbar,
border_color="white",
alpha=0.8,
fill_color="lightgray",
metadata_name='selections'))
#ipshell('colorbar, colorbar_selection and ovr available:')
self.cbar_selection=colorbar_selection
self.cmap_renderer=cmap_renderer
colorbar.plot = cmap_renderer
colorbar.padding_top = scatplot.padding_top
colorbar.padding_bottom = scatplot.padding_bottom
self.colorbar=colorbar
return colorbar
color_mapper=colormap,
plot=self.my_plot,
orientation='v',
resizable='v',
width=30,
padding=20)
self.colorbar.padding_top = self.tplot.padding_top
self.colorbar.padding_bottom = self.tplot.padding_bottom
# TODO: the range selection gives a Segmentation Fault,
# but why, the matrix_viewer.py example works just fine!
# create a range selection for the colorbar
self.range_selection = RangeSelection(component=self.colorbar)
self.colorbar.tools.append(self.range_selection)
self.colorbar.overlays.append(RangeSelectionOverlay(component=self.colorbar,
border_color="white",
alpha=0.8,
fill_color="lightgray"))
# we also want to the range selection to inform the cmap plot of
# the selection, so set that up as well
#self.range_selection.listeners.append(self.my_plot)
# Create a container to position the plot and the colorbar side-by-side
container = HPlotContainer(use_backbuffer = True)
container.add(self.tplot)
container.add(self.colorbar)
container.bgcolor = "white"
# my_plot.set_value_selection((-1.3, 6.9))
inds=range(len(self.df.index))
idx=ArrayDataSource(inds)
vals=ArrayDataSource(df.index.values)
index_range = DataRange1D(idx)
val_range=DataRange1D(vals)
imap=LinearMapper(range=index_range)#,stretch_data=self.index_mapper.stretch_data)
vmap=LinearMapper(range=val_range)
# mycomp.index_range.refresh()
mycomp.index_mapper=imap
mycomp.value_mapper=vmap
self.rangeselect=RangeSelection(mycomp, axis=self.selection_axis)
self.plot.active_tool = self.rangeselect
self.plot.overlays.append(RangeSelectionOverlay(component=mycomp))
self.rangeselect.on_trait_change(self.on_selection_changed, "selection")