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_plot_component():
container = OverlayPlotContainer(padding = 50, fill_padding = True,
bgcolor = "lightgray", use_backbuffer=True)
# Create the initial X-series of data
numpoints = 30
low = -5
high = 15.0
x = linspace(low, high, numpoints)
y = jn(0, x)
lineplot = create_line_plot((x,y), color=tuple(COLOR_PALETTE[0]), width=2.0)
lineplot.selected_color = "none"
scatter = ScatterPlot(index = lineplot.index,
value = lineplot.value,
index_mapper = lineplot.index_mapper,
value_mapper = lineplot.value_mapper,
color = tuple(COLOR_PALETTE[0]),
rect1.overlays.append(Overlay("One", component=rect1))
rect2.overlays.append(Overlay("Two", component=rect2))
container1 = OverlayPlotContainer(bounds=[400, 400], resizable="")
container1.add(rect1, rect2)
container1.bgcolor = (0.60, 0.98, 0.60, 0.5) #"palegreen"
rect3 = Region("purple", position=[50, 50])
rect4 = Region("teal", position=[200, 50])
rect3.overlays.append(Overlay("Three", component=rect3))
rect4.overlays.append(Overlay("Four", component=rect4))
container2 = OverlayPlotContainer(bounds=[400, 400], resizable="")
container2.add(rect3, rect4)
container2.bgcolor = "navajowhite"
container2.position = [200, 200]
top_container = OverlayPlotContainer()
top_container.add(container1, container2)
return Window(self, -1, component=top_container)
OverlayPlotContainer.draw(self, gc, *args, **kw)
class GraphicGeneratorController(Controller):
def traits_view(self):
v = View(
UItem('container', editor=ComponentEditor(),
style='custom'),
width=500,
height=500,
resizable=True,
)
return v
class GraphicModel(HasTraits):
container = Instance(OverlayPlotContainer)
def load(self):
data = ArrayPlotData()
p = Plot(data=data, padding=100)
X = linspace(0, 2 * pi)
data.set_data('x0', X)
data.set_data('y0', cos(X))
p.plot(('x0', 'y0'))
self.container.add(p)
def _container_default(self):
c = RotatingContainer(bgcolor='white')
return c
if __name__ == '__main__':
def __init__(self, *args, **kws):
super(OverlayPlotContainer, self).__init__(*args, **kws)
self._setup_plots()
def main():
plot = create_plot()
plot.bounds = [400,300]
plot.outer_position = [30,30]
plot.resizable = ""
cmap_renderer = plot.plots["my_plot"][0]
# Create the colorbar, handing in the appropriate range and colormap
colorbar = create_colorbar(plot.color_mapper)
colorbar.outer_position = [450,30]
colorbar.plot = cmap_renderer
colorbar.padding_top = plot.padding_top
colorbar.padding_bottom = plot.padding_bottom
container = OverlayPlotContainer(bgcolor = "transparent",
fit_window = True)
container.add(plot)
container.add(colorbar)
start_vtk(container)
def _plot_default(self):
container = OverlayPlotContainer(bgcolor = "white")
plots = self._make_curves()
for plot in plots:
plot.padding = 60
container.add(plot)
bottom_axis = PlotAxis(plot, orientation='bottom')
label_list=['var a', 'var b', 'var c', 'var d', 'var e', 'var f',
'var g', 'var h', 'var i']
vertical_axis = LabelAxis(plot, orientation='left',
title='Categories',
positions = list(range(1, 10)),
labels=label_list)
vertical2_axis = LabelAxis(plot, orientation='right',
positions = list(range(1, 10)),
labels=label_list)
selection_color = "lawngreen")
)
scatter.index.on_trait_change(self._metadata_handler,
"metadata_changed")
scatter.tools.append(PanTool(scatter, drag_button='right'))
scatter.tools.append(ZoomTool(scatter))
plot.index_axis.title = "Longitude"
plot.index_axis.tick_label_formatter = self._convert_lon
plot.value_axis.title = "Latitude"
plot.value_axis.tick_label_formatter = self._convert_lat
plot.padding_right = plot.padding_top = 2
container = OverlayPlotContainer(
use_backbuffer=True,
bgcolor = "sys_window"
)
container.add(plot)
container.bgcolor = "sys_window"
return container
quiverplot = QuiverPlot(index = xs, value = ys,
vectors = vector_ds,
index_mapper = LinearMapper(range=xrange),
value_mapper = LinearMapper(range=yrange),
bgcolor = "white")
add_default_axes(quiverplot)
add_default_grids(quiverplot)
# Attach some tools to the plot
quiverplot.tools.append(PanTool(quiverplot, constrain_key="shift"))
zoom = ZoomTool(quiverplot)
quiverplot.overlays.append(zoom)
container = OverlayPlotContainer(quiverplot, padding=50)
return container