本文整理汇总了Python中enthought.chaco.api.OverlayPlotContainer.add方法的典型用法代码示例。如果您正苦于以下问题:Python OverlayPlotContainer.add方法的具体用法?Python OverlayPlotContainer.add怎么用?Python OverlayPlotContainer.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enthought.chaco.api.OverlayPlotContainer
的用法示例。
在下文中一共展示了OverlayPlotContainer.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_plot_component
# 需要导入模块: from enthought.chaco.api import OverlayPlotContainer [as 别名]
# 或者: from enthought.chaco.api.OverlayPlotContainer import add [as 别名]
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
示例2: _create_window
# 需要导入模块: from enthought.chaco.api import OverlayPlotContainer [as 别名]
# 或者: from enthought.chaco.api.OverlayPlotContainer import add [as 别名]
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)
示例3: slice_plot
# 需要导入模块: from enthought.chaco.api import OverlayPlotContainer [as 别名]
# 或者: from enthought.chaco.api.OverlayPlotContainer import add [as 别名]
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
示例4: init
# 需要导入模块: from enthought.chaco.api import OverlayPlotContainer [as 别名]
# 或者: from enthought.chaco.api.OverlayPlotContainer import add [as 别名]
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))
示例5: _container_default
# 需要导入模块: from enthought.chaco.api import OverlayPlotContainer [as 别名]
# 或者: from enthought.chaco.api.OverlayPlotContainer import add [as 别名]
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: _create_draggable_plot_component
# 需要导入模块: from enthought.chaco.api import OverlayPlotContainer [as 别名]
# 或者: from enthought.chaco.api.OverlayPlotContainer import add [as 别名]
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
示例7: test_min_size
# 需要导入模块: from enthought.chaco.api import OverlayPlotContainer [as 别名]
# 或者: from enthought.chaco.api.OverlayPlotContainer import add [as 别名]
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
示例8: _create_plot_component
# 需要导入模块: from enthought.chaco.api import OverlayPlotContainer [as 别名]
# 或者: from enthought.chaco.api.OverlayPlotContainer import add [as 别名]
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
示例9: test_multiple_min_size
# 需要导入模块: from enthought.chaco.api import OverlayPlotContainer [as 别名]
# 或者: from enthought.chaco.api.OverlayPlotContainer import add [as 别名]
def test_multiple_min_size(self):
comp1 = StaticPlotComponent([200, 50])
comp2 = StaticPlotComponent([60, 300])
container = OverlayPlotContainer(resizable='hv', bounds=[30,30])
container.fit_components = "hv"
container.add(comp1, comp2)
container.do_layout()
self.assert_tuple(container.get_preferred_size(), (200,300))
self.assert_tuple(comp1.bounds, (200,50))
self.assert_tuple(comp2.bounds, (60,300))
return
示例10: _create_plot_component
# 需要导入模块: from enthought.chaco.api import OverlayPlotContainer [as 别名]
# 或者: from enthought.chaco.api.OverlayPlotContainer import add [as 别名]
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__
# 需要导入模块: from enthought.chaco.api import OverlayPlotContainer [as 别名]
# 或者: from enthought.chaco.api.OverlayPlotContainer import add [as 别名]
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
# 需要导入模块: from enthought.chaco.api import OverlayPlotContainer [as 别名]
# 或者: from enthought.chaco.api.OverlayPlotContainer import add [as 别名]
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: main
# 需要导入模块: from enthought.chaco.api import OverlayPlotContainer [as 别名]
# 或者: from enthought.chaco.api.OverlayPlotContainer import add [as 别名]
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
示例14: test_fixed_size_component
# 需要导入模块: from enthought.chaco.api import OverlayPlotContainer [as 别名]
# 或者: from enthought.chaco.api.OverlayPlotContainer import add [as 别名]
def test_fixed_size_component(self):
container = OverlayPlotContainer(resizable='', bounds=[200.0,300.0])
# non-resizable component
component = PlotComponent(resizable='', position=[50.0,60.0], bounds=[100.0,110.0])
self.assertEquals(container._layout_needed, True)
container.do_layout()
container.add(component)
self.assertEquals(container._layout_needed, True)
container.do_layout()
self.assertEquals(container._layout_needed, False)
# check the results of the layout
self.assert_tuple(container.get_preferred_size(), (200.0,300.0))
self.assert_tuple(component.position, (50.0,60.0))
self.assert_tuple(component.bounds, (100.0,110.0))
return
示例15: _create_plot_component
# 需要导入模块: from enthought.chaco.api import OverlayPlotContainer [as 别名]
# 或者: from enthought.chaco.api.OverlayPlotContainer import add [as 别名]
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]),
marker_size = 5)
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)
scatter.tools.append(PointDraggingTool(scatter))
container.add(lineplot)
container.add(scatter)
# Add the title at the top
container.overlays.append(PlotLabel("Line Editor",
component=container,
font = "swiss 16",
overlay_position="top"))
return container