本文整理汇总了Python中enthought.chaco.api.OverlayPlotContainer类的典型用法代码示例。如果您正苦于以下问题:Python OverlayPlotContainer类的具体用法?Python OverlayPlotContainer怎么用?Python OverlayPlotContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OverlayPlotContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_window
def _create_window(self):
ts = touchstone.read("../tests/data/deemb_mom.s2p")
ts = ts.recombine([1, 2])
circles_source = np.vstack(ts.stability_circle_source()).T
circles_load = np.vstack(ts.stability_circle_load()).T
container = OverlayPlotContainer(padding=50, fill_padding=True, bgcolor="lightgray", use_backbuffer=True)
self.data = ArrayPlotData(
f=ts.freqs,
s11=ts.get_parameter(1, 1),
s12=ts.get_parameter(1, 2),
s21=ts.get_parameter(2, 1),
s22=ts.get_parameter(2, 2),
circles_source=circles_source,
circles_load=circles_load,
)
self.plot = SmithPlot(self.data, title="Smith plot")
self.plot.plot(("f", "s11"), color="auto", line_width=2.0)
self.plot.plot(("f", "s22"), color="auto", line_width=2.0)
# self.plot.plot(("f", "s21"), color="auto", line_width=2.0)
# self.plot.plot(("f", "s12"), color="auto", line_width=2.0)
self.plot.plot_circle(("f", "circles_source"), color="auto", line_width=2.0)
self.plot.plot_circle(("f", "circles_load"), color="auto", line_width=2.0)
container.add(self.plot)
self.plot.tools.append(PanTool(self.plot))
zoom = SimpleZoom(self.plot, tool_mode="box", always_on=False)
self.plot.overlays.append(zoom)
return Window(self, -1, component=container)
示例2: _create_plot_component
def _create_plot_component():
container = OverlayPlotContainer(padding = 50, fill_padding = True,
bgcolor = "lightgray", use_backbuffer=True)
# Create the initial X-series of data
numpoints = 100
low = -5
high = 15.0
x = arange(low, high+0.001, (high-low)/numpoints)
# Plot some bessel functions
plots = {}
broadcaster = BroadcasterTool()
for i in range(4):
y = jn(i, x)
plot = create_line_plot((x,y), color=tuple(COLOR_PALETTE[i]), width=2.0)
plot.index.sort_order = "ascending"
plot.bgcolor = "white"
plot.border_visible = True
if i == 0:
add_default_grids(plot)
add_default_axes(plot)
# Create a pan tool and give it a reference to the plot it should
# manipulate, but don't attach it to the plot. Instead, attach it to
# the broadcaster.
pan = PanTool(plot)
broadcaster.tools.append(pan)
container.add(plot)
plots["Bessel j_%d"%i] = plot
# Add an axis on the right-hand side that corresponds to the second plot.
# Note that it uses plot.value_mapper instead of plot0.value_mapper.
plot1 = plots["Bessel j_1"]
axis = PlotAxis(plot1, orientation="right")
plot1.underlays.append(axis)
# Add the broadcast tool to the container, instead of to an
# individual plot
container.tools.append(broadcaster)
legend = Legend(component=container, padding=10, align="ur")
legend.tools.append(LegendTool(legend, drag_button="right"))
container.overlays.append(legend)
# Set the list of plots on the legend
legend.plots = plots
# Add the title at the top
container.overlays.append(PlotLabel("Bessel functions",
component=container,
font = "swiss 16",
overlay_position="top"))
# Add the traits inspector tool to the container
container.tools.append(TraitsTool(container))
return container
示例3: init
def init(self, parent):
factory = self.factory
container = OverlayPlotContainer(bgcolor='transparent',
padding=0, spacing=0)
window = Window(parent, component=container)
interval = self.high - self.low
data = ([self.low, self.high], [0.5]*2)
plot = create_line_plot(data, color='black', bgcolor="sys_window")
plot.x_mapper.range.low = self.low - interval*0.1
plot.x_mapper.range.high = self.high + interval*0.1
plot.y_mapper.range.high = 1.0
plot.y_mapper.range.low = 0.0
range_selection = RangeSelection(plot, left_button_selects=True)
# Do not allow the user to reset the range
range_selection.event_state = "selected"
range_selection.deselect = lambda x: None
range_selection.on_trait_change(self.update_interval, 'selection')
plot.tools.append(range_selection)
plot.overlays.append(RangeKnobsOverlay(plot))
self.plot = plot
container.add(self.plot)
# To set the low and high, we're actually going to set the
# 'selection' metadata on the line plot to the tuple (low,high).
plot.index.metadata["selections"] = (0, 1.0)
# Tell the editor what to display
self.control = window.control
self.control.SetSize((factory.width, factory.height))
示例4: test_basics
def test_basics(self):
container = OverlayPlotContainer(resizable='', bounds=[100.0,200.0])
self.assert_tuple(container.get_preferred_size(), (100.0,200.0))
self.assertEquals(container._layout_needed, True)
container.do_layout()
self.assertEquals(container._layout_needed, False)
return
示例5: _container_default
def _container_default(self):
self.plot = None
# Create the data and datasource objects
# In order for the date axis to work, the index data points need to
# be in units of seconds since the epoch. This is because we are using
# the CalendarScaleSystem, whose formatters interpret the numerical values
# as seconds since the epoch.
numpoints = 500
index = create_dates(numpoints)
returns = random.lognormal(0.00, 0.04, size=numpoints)
average = 100.0 * cumprod(returns)
high = average + abs(random.normal(0, 20.0, size=numpoints))
low = average - abs(random.normal(0, 20.0, size=numpoints))
delta = high - low
open = low + delta * random.uniform(0.05, 0.95, size=numpoints)
close = low + delta * random.uniform(0.05, 0.95, size=numpoints)
price = vstack((open, high, low, close, average))
time_ds = ArrayDataSource(index)
price_ds = PriceDataSource(price, sort_order="none")
# Create the price plot
price_plot = self._create_plot(time_ds, price_ds)
self.plot = price_plot
container = OverlayPlotContainer(padding=35)
container.add(price_plot)
return container
示例6: __init__
def __init__(self, **traits):
super(ContainerExample, self).__init__(**traits)
x = np.linspace(-14, 14, 100)
y = np.sin(x) * x**3 / 1000
data = ArrayPlotData(x=x, y=y)
p1 = Plot(data, padding=30)
p1.plot(("x", "y"), type="scatter", color="blue")
p1.plot(("x", "y"), type="line", color="blue")
p2 = Plot(data, padding=30)
p2.plot(("x", "y"), type="line", color="blue")
p2.set(bounds = [200, 100], position = [70,150],
bgcolor = (0.9,0.9,0.9), unified_draw=True, resizable="")
p3 = Plot(data, padding=30)
p3.plot(("x", "y"), type="line", color="blue", line_width=2.0)
p4 = Plot(data, padding=30)
p4.plot(("x", "y"), type="scatter", color="red", marker="circle")
c1 = OverlayPlotContainer(p1, p2)
c1.fixed_preferred_size = p3.get_preferred_size()
c2 = HPlotContainer(c1, p3)
c3 = VPlotContainer(p4, c2)
self.plot = c3
示例7: slice_plot
def slice_plot( self, anat, coefs, **traits ):
p = Plot( self.plot_data, default_origin = 'bottom left' )
p2 = Plot( self.plot_data, default_origin = 'bottom left' )
p.x_axis.visible = False; p2.x_axis.visible = False
p.y_axis.visible = False; p2.y_axis.visible = False
bounds = self.plot_data.get_data(anat).shape
asp = float( bounds[1] ) / float( bounds[0] )
p.img_plot( anat,
# xbounds = np.linspace( 0, 1, bounds[1] + 1 ),
# ybounds = np.linspace( 0, 1, bounds[0] + 1 ),
colormap = chaco_colormaps.gray )
p2.img_plot( coefs,
# xbounds = np.linspace( 0, 1, bounds[1] + 1 ),
# ybounds = np.linspace( 0, 1, bounds[0] + 1 ),
# bgcolor = 'transparent',
colormap = self.cmap,
interpolation = 'nearest')
# p.aspect_ratio = asp; p2.aspect_ratio = asp
p.aspect_ratio = asp; p2.aspect_ratio = asp
subplot = OverlayPlotContainer( )
subplot.add( p )
subplot.add( p2 )
return subplot
示例8: test_min_size
def test_min_size(self):
container = OverlayPlotContainer(resizable='', bounds=[50.0,50.0])
component = PlotComponent(resizable='', position=[50.0,60.0],
bounds=[100.0, 110.0])
container.add(component)
container.do_layout()
self.assert_tuple(component.position, (50.0,60.0))
self.assert_tuple(component.bounds, (100.0,110.0))
return
示例9: _create_plot_component
def _create_plot_component():
container = OverlayPlotContainer(padding = 50, fill_padding = True,
bgcolor = "lightgray", use_backbuffer=True)
# Create the initial X-series of data
numpoints = 100
low = -5
high = 15.0
x = arange(low, high+0.001, (high-low)/numpoints)
y = jn(0, x)
plot = create_line_plot((x,y), color=tuple(COLOR_PALETTE[0]), width=2.0)
plot.index.sort_order = "ascending"
plot.bgcolor = "white"
plot.border_visible = True
add_default_grids(plot)
add_default_axes(plot)
# Add some tools
plot.tools.append(PanTool(plot))
zoom = ZoomTool(plot, tool_mode="box", always_on=False)
plot.overlays.append(zoom)
# Add a dynamic label. This can be dragged and moved around using the
# right mouse button. Note the use of padding to offset the label
# from its data point.
label = DataLabel(component=plot, data_point=(x[40], y[40]),
label_position="top left", padding=40,
bgcolor = "lightgray",
border_visible=False)
plot.overlays.append(label)
tool = DataLabelTool(label, drag_button="right", auto_arrow_root=True)
label.tools.append(tool)
# Add some static labels.
label2 = DataLabel(component=plot, data_point=(x[20], y[20]),
label_position="bottom right",
border_visible=False,
bgcolor="transparent",
marker_color="blue",
marker_line_color="transparent",
marker = "diamond",
arrow_visible=False)
plot.overlays.append(label2)
label3 = DataLabel(component=plot, data_point=(x[80], y[80]),
label_position="top", padding_bottom=20,
marker_color="transparent",
marker_size=8,
marker="circle",
arrow_visible=False)
plot.overlays.append(label3)
container.add(plot)
return container
示例10: _create_plot_component
def _create_plot_component():
# Create some x-y data series to plot
plot_area = OverlayPlotContainer(border_visible=True)
container = HPlotContainer(padding=50, bgcolor="transparent")
#container.spacing = 15
x = linspace(-2.0, 10.0, 100)
for i in range(5):
color = tuple(COLOR_PALETTE[i])
y = jn(i, x)
renderer = create_line_plot((x, y), color=color)
plot_area.add(renderer)
#plot_area.padding_left = 20
axis = PlotAxis(orientation="left", resizable="v",
mapper = renderer.y_mapper,
axis_line_color=color,
tick_color=color,
tick_label_color=color,
title_color=color,
bgcolor="transparent",
title = "jn_%d" % i,
border_visible = True,)
axis.bounds = [60,0]
axis.padding_left = 10
axis.padding_right = 10
container.add(axis)
if i == 4:
# Use the last plot's X mapper to create an X axis and a
# vertical grid
x_axis = PlotAxis(orientation="bottom", component=renderer,
mapper=renderer.x_mapper)
renderer.overlays.append(x_axis)
grid = PlotGrid(mapper=renderer.x_mapper, orientation="vertical",
line_color="lightgray", line_style="dot")
renderer.underlays.append(grid)
# Add the plot_area to the horizontal container
container.add(plot_area)
# Attach some tools to the plot
broadcaster = BroadcasterTool()
for plot in plot_area.components:
broadcaster.tools.append(PanTool(plot))
# Attach the broadcaster to one of the plots. The choice of which
# plot doesn't really matter, as long as one of them has a reference
# to the tool and will hand events to it.
plot.tools.append(broadcaster)
return container
示例11: __init__
def __init__(self, link):
super(TrackingView, self).__init__()
self.link = link
self.link.add_callback(MSG_TRACKING_SNRS, self.tracking_snrs_callback)
# ======= Line Plot =======
self.plot_data = ArrayPlotData(t=[0.0])
self.plot = Plot(self.plot_data, auto_colors=colours_list)
self.plot.value_range.tight_bounds = False
self.plot.value_range.low_setting = 0.0
for n in range(TRACK_N_CHANNELS):
self.plot_data.set_data('ch'+str(n), [0.0])
self.plot.plot(('t', 'ch'+str(n)), type='line', color='auto')
# ======= Bar Plot =======
idxs = ArrayDataSource(range(1, len(self.snrs)+1))
self.vals = ArrayDataSource(self.snrs, sort_order='none')
# Create the index range
index_range = DataRange1D(idxs, low=0.4, high=TRACK_N_CHANNELS+0.6)
index_mapper = LinearMapper(range=index_range)
# Create the value range
value_range = DataRange1D(low=0.0, high=25.0)
value_mapper = LinearMapper(range=value_range)
plot = BarPlot(index=idxs, value=self.vals,
index_mapper=index_mapper, value_mapper=value_mapper,
line_color='blue', fill_color='blue', bar_width=0.8)
container = OverlayPlotContainer(bgcolor = "white")
plot.padding = 10
plot.padding_left = 30
plot.padding_bottom = 30
container.add(plot)
left_axis = PlotAxis(plot, orientation='left')
bottom_axis = LabelAxis(plot, orientation='bottom',
labels = map(str, range(1, TRACK_N_CHANNELS+1)),
positions = range(1, TRACK_N_CHANNELS+1),
small_haxis_style=True)
plot.underlays.append(left_axis)
plot.underlays.append(bottom_axis)
self.snr_bars = container
self.python_console_cmds = {
'track': self
}
示例12: _create_spectrumplot
def _create_spectrumplot(self, x, y):
spectrumplot = create_line_plot((x, y), index_bounds=None, value_bounds=None,
orientation='v', color='green', width=1.0, dash='solid',
value_mapper_class=LinearMapper,
bgcolor='transparent', border_visible=True,
add_grid=False, add_axis=False, index_sort='ascending')
add_default_axes(spectrumplot, orientation='flipped', vtitle='Frequency [MHz]', htitle='Amplitude')
spectrumplot.origin = "top left"
spectrumplot.tools.append(PanTool(spectrumplot, drag_button="right"))
zoom = SimpleZoom(component=spectrumplot, tool_mode="box", drag_button="left", always_on=True)
spectrumplot.overlays.append(zoom)
container = OverlayPlotContainer(padding=40, padding_left=60)
container.add(spectrumplot)
self.container = container
示例13: _create_draggable_plot_component
def _create_draggable_plot_component(title, initial_values=None, on_change_functor=None):
container = OverlayPlotContainer(padding = 30, fill_padding = True,
bgcolor = "lightgray", use_backbuffer=True)
if initial_values:
x = initial_values[0]
y = initial_values[1]
else:
# 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]),
marker_size=2,
)
scatter.index.sort_order = 'ascending'
scatter.bgcolor = 'white'
scatter.border_visible = True
add_default_grids(scatter)
add_default_axes(scatter)
scatter.tools.append(PanTool(scatter, drag_button='right'))
# The ZoomTool tool is stateful and allows drawing a zoom
# box to select a zoom region.
zoom = ZoomTool(scatter, tool_mode='box', always_on=False,
drag_button=None)
scatter.overlays.append(zoom)
point_dragging_tool = PointDraggingTool(scatter)
point_dragging_tool.on_change_functor = on_change_functor
scatter.tools.append(point_dragging_tool)
container.add(lineplot)
container.add(scatter)
# Add the title at the top
container.overlays.append(PlotLabel(title, component=container,
font='swiss 16', overlay_position='top'))
container.mx = lineplot.index.get_data()
container.my = lineplot.value.get_data()
container.lineplot = lineplot
return container
示例14: main
def main():
# Create some x-y data series to plot
x = linspace(-2.0, 10.0, 100)
pd = ArrayPlotData(index = x)
for i in range(5):
pd.set_data("y" + str(i), jn(i,x))
# Create some line plots of some of the data
plot = Plot(pd, bgcolor="none", padding=30, border_visible=True,
overlay_border=True, use_backbuffer=False)
plot.legend.visible = True
plot.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="auto")
plot.plot(("index", "y3"), name="j_3", color="auto")
plot.tools.append(PanTool(plot))
zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
plot.overlays.append(zoom)
# Create the mlab test mesh and get references to various parts of the
# VTK pipeline
f = mlab.figure(size=(600,500))
m = mlab.test_mesh()
scene = mlab.gcf().scene
render_window = scene.render_window
renderer = scene.renderer
rwi = scene.interactor
plot.resizable = ""
plot.bounds = [200,200]
plot.padding = 25
plot.outer_position = [30,30]
plot.tools.append(MoveTool(component=plot,drag_button="right"))
container = OverlayPlotContainer(bgcolor = "transparent",
fit_window = True)
container.add(plot)
# Create the Enable Window
window = EnableVTKWindow(rwi, renderer,
component=container,
#istyle_class = tvtk.InteractorStyleSwitch,
#istyle_class = tvtk.InteractorStyle,
istyle_class = tvtk.InteractorStyleTrackballCamera,
bgcolor = "transparent",
event_passthrough = True,
)
mlab.show()
return window, render_window
示例15: _plot_default
def _plot_default(self):
container = OverlayPlotContainer(bgcolor = "white")
self.idx = ArrayDataSource( range(1, self.binsNum+1) )
self.vals = ArrayDataSource(self.value_points, sort_order="none")
index_range = DataRange1D(self.idx, low=0, high=self.binsNum+2 )
index_mapper = LinearMapper(range=index_range)
value_range = DataRange1D(low=0, high=self.value_points.max())
value_mapper = LinearMapper(range=value_range)
# Create the plot
self.histPlot = BarPlot(index=self.idx, value=self.vals,
value_mapper=value_mapper,
index_mapper=index_mapper,
line_color='black',
fill_color=tuple(COLOR_PALETTE[1]),
bar_width=0.8, antialias=False)
plots = [self.histPlot]
for plot in plots:
plot.padding = 50
plot.padding_left = 80
plot.padding_top = 30
container.add(plot)
left_axis = PlotAxis(plot, orientation='left',
title='Number / Probability',
positions = [num for num in self.value_points],
labels = ["%.2f" % num for num in self.value_points],
#small_haxis_style=True
)
bottom_axis = LabelAxis(plot, orientation='bottom',
title='Values',
positions = range(1, self.binsNum+1),
labels = ["%.2f" % num for num in self.index_points],
)
plot.underlays.append(left_axis)
plot.underlays.append(bottom_axis)
return container