Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
plot.x_grid.visible = False
plot.y_grid.visible = False
plot.x_axis.font = "modern 16"
plot.y_axis.font = "modern 16"
# Right now, some of the tools are a little invasive, and we need the
# actual ColomappedSegmentPlot object to give to them
cmap_renderer = plot.plots["my_plot"][0]
# Attach some tools to the plot
plot.tools.append(PanTool(plot, constrain_key="shift"))
zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
plot.overlays.append(zoom)
# Create the colorbar, handing in the appropriate range and colormap
colorbar = ColorBar(index_mapper=LinearMapper(range=plot.color_mapper.range),
color_mapper=plot.color_mapper,
orientation='v',
resizable='v',
width=30,
padding=20)
colorbar.plot = cmap_renderer
colorbar.padding_top = plot.padding_top
colorbar.padding_bottom = plot.padding_bottom
# 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"
return container
def draw_colorbar(self):
scatplot=self.scatplot
cmap_renderer = scatplot.plots["my_plot"][0]
selection = ColormappedSelectionOverlay(cmap_renderer, fade_alpha=0.35,
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
# Right now, some of the tools are a little invasive, and we need the
# actual CMapImage object to give to them
self.my_plot = self.tplot.plots["my_plot"][0]
# Attach some tools to the plot
self.tplot.tools.append(PanTool(self.tplot))
zoom = ZoomTool(component=self.tplot, tool_mode="box", always_on=False)
self.tplot.overlays.append(zoom)
# my custom tool to get the connection information
self.custtool = CustomTool(self.tplot)
self.tplot.tools.append(self.custtool)
# Create the colorbar, handing in the appropriate range and colormap
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
# 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,
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
index_mapper = index_mapper,
value_mapper = LinearMapper(range=value_range, stretch_data=False),
fill_color = (0.81960784, 0.89803922, 0.94117647),
edge_color = 'transparent',
)
filled.tools.append(PanTool(filled, constrain=True, constrain_direction="x"))
axis = PlotAxis(mapper = filled.value_mapper, component=filled, orientation="left",
tick_label_position="outside")
filled.overlays.append(axis)
grid = PlotGrid(mapper = filled.value_mapper, component=filled, orientation='horizontal',
line_color='lightgray', line_style="dot",)
filled.underlays.append(grid)
colormap = horizon.color_mapper
colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range),
color_mapper=colormap,
orientation='v',
resizable='v',
width=20,
padding=20)
padding = (40, 20, 0, 0)
over1 = HPlotContainer(use_backbuffer=True, padding=padding, padding_top=20)
over1.add(filled)
over1.add(colorbar)
over2 = OverlayPlotContainer(padding = padding, padding_bottom=40)
over2.add(horizon)
return over1, over2
if name in ['function', 'npts_x', 'npts_y',
'min_x', 'max_x', 'min_y', 'max_y']:
self.compute_model()
class PlotUI(HasTraits):
# container for all plots
container = Instance(HPlotContainer)
# Plot components within this container:
polyplot = Instance(ContourPolyPlot)
lineplot = Instance(ContourLinePlot)
cross_plot = Instance(Plot)
cross_plot2 = Instance(Plot)
colorbar = Instance(ColorBar)
# plot data
pd = Instance(ArrayPlotData)
# view options
num_levels = Int(15)
colormap = Enum(colormaps)
#Traits view definitions:
traits_view = View(
Group(UItem('container', editor=ComponentEditor(size=(800,600)))),
resizable=True)
plot_edit_view = View(
Group(Item('num_levels'),
Item('colormap')),
# Right now, some of the tools are a little invasive, and we need the
# actual CMapImage object to give to them
self.my_plot = self.tplot.plots["my_plot"][0]
# Attach some tools to the plot
self.tplot.tools.append(PanTool(self.tplot))
zoom = ZoomTool(component=self.tplot, tool_mode="box", always_on=False)
self.tplot.overlays.append(zoom)
# my custom tool to get the connection information
self.custtool = CustomTool(self.tplot)
self.tplot.tools.append(self.custtool)
# Create the colorbar, handing in the appropriate range and colormap
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,
lplot.padding = 20
lplot.bg_color = "white"
lplot.fill_padding = True
# Add some tools to the plot
zoom = ZoomTool(lplot, tool_mode="box", always_on=False)
lplot.overlays.append(zoom)
lplot.tools.append(PanTool(lplot, constrain_key="shift"))
# Right now, some of the tools are a little invasive, and we need the
# actual CMapImage object to give to them
cm_plot = lplot.plots["cm_plot"][0]
# Create the colorbar, handing in the appropriate range and colormap
colormap = cm_plot.color_mapper
colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range),
color_mapper=colormap,
plot=cm_plot,
orientation='v',
resizable='v',
width=30,
padding=20)
colorbar.padding_top = lplot.padding_top
colorbar.padding_bottom = lplot.padding_bottom
# Create the left plot, contours of varying color and width
rplot = Plot(pd, range2d=lplot.range2d)
rplot.contour_plot("imagedata",
type="line",
xbounds=x_extents,
ybounds=y_extents,
bgcolor="black",