本文整理汇总了Python中chaco.api.VPlotContainer.add方法的典型用法代码示例。如果您正苦于以下问题:Python VPlotContainer.add方法的具体用法?Python VPlotContainer.add怎么用?Python VPlotContainer.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chaco.api.VPlotContainer
的用法示例。
在下文中一共展示了VPlotContainer.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_plot_component
# 需要导入模块: from chaco.api import VPlotContainer [as 别名]
# 或者: from chaco.api.VPlotContainer import add [as 别名]
def _create_plot_component(obj):
# Spectrogram plot
obj.data = fr.getDataSets(".chi")
frequencies = obj.data[0][0]
index = ArrayDataSource(data=frequencies)
values = [obj.data[i][1] for i in xrange(len(obj.data))]
print len(obj.data[1][1])
print len(obj.data)
p = WaterfallRenderer(
index=index,
values=values,
index_mapper=LinearMapper(range=DataRange1D(low=0, high=SPECTROGRAM_LENGTH)),
value_mapper=LinearMapper(range=DataRange1D(low=0, high=SPECTROGRAM_LENGTH)),
x2_mapper=LinearMapper(low_pos=0, high_pos=100, range=DataRange1D(low=10.0, high=101.0)),
y2_mapper=LinearMapper(low_pos=0, high_pos=100, range=DataRange1D(low=0, high=600000)),
)
spectrogram_plot = p
obj.spectrogram_plot = p
dummy = Plot()
dummy.padding = 50
dummy.index_axis.mapper.range = p.index_mapper.range
dummy.index_axis.title = "Frequency (hz)"
dummy.add(p)
c2 = VPlotContainer()
c2.add(dummy)
return c2
示例2: WaveformDisplay
# 需要导入模块: from chaco.api import VPlotContainer [as 别名]
# 或者: from chaco.api.VPlotContainer import add [as 别名]
class WaveformDisplay(TwoDimensionalPlot):
marker_height = 50
def __init__(self, parent, *args, **kwargs):
TwoDimensionalPlot.__init__(self, parent, *args, **kwargs)
self.padding_left = 50
self.title = 'Waveform'
self.vplot_container = VPlotContainer(use_backbuffer=True)
self.vplot_container.stack_order = 'top_to_bottom'
self.vplot_container.add(self)
@property
def control(self):
return Window(self.parent, component=self.vplot_container).control
def add_marker(self, num, data):
marker_plot = TwoDimensionalPlot(self, height=self.marker_height, resizable='h')
marker_plot.padding_left = self.padding_left
marker_plot.x_data = self.x_data
marker_plot.y_data = data
marker_plot.title = 'Marker {0}'.format(num)
# Synchronize with waveform plot.
marker_plot.index_range = self.index_range
self.vplot_container.add(marker_plot)
示例3: _create_plot_component
# 需要导入模块: from chaco.api import VPlotContainer [as 别名]
# 或者: from chaco.api.VPlotContainer import add [as 别名]
def _create_plot_component():
# 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
plot1 = Plot(pd, padding=50)
plot1.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="red")
plot1.plot(("index", "y3"), name="j_3", color="blue")
# Attach some tools to the plot
plot1.tools.append(PanTool(plot1))
zoom = ZoomTool(component=plot1, tool_mode="box", always_on=False)
plot1.overlays.append(zoom)
# Add the scrollbar
hscrollbar = PlotScrollBar(component=plot1, axis="index", resizable="h",
height=15)
plot1.padding_top = 0
hscrollbar.force_data_update()
# Create a container and add our plots
container = VPlotContainer()
container.add(plot1)
container.add(hscrollbar)
return container
示例4: create_vplot
# 需要导入模块: from chaco.api import VPlotContainer [as 别名]
# 或者: from chaco.api.VPlotContainer import add [as 别名]
def create_vplot(self):
''' fill vplot container with 1 mini plot for range selection
and N main plots ordered from to top to bottom by freq
'''
vpc = VPlotContainer(bgcolor='lightgrey')
if self.model.freq_choices:
# create mini plot using the highest freq as background
keys = self.model.freq_choices
mini = self.create_hplot(key=keys[-1], mini=True)
self.mini_hplot = mini
vpc.add(mini)
# create hplot containers for each freq and add to dict.
# dictionary will be used to access these later to individually
# address them to turn them on or off etc.
# note these are added with lowest freq on bottom
for freq in self.model.freq_choices:
hpc = self.create_hplot(key=freq)
self.hplot_dict[freq] = hpc
vpc.add(hpc)
# add tool to freeze line inspector cursor when in desired position
vpc.tools.append(self.inspector_freeze_tool)
self.vplot_container = vpc
self.set_hplot_visibility(all=True)
self.set_intensity_profile_visibility()
示例5: _plot_default
# 需要导入模块: from chaco.api import VPlotContainer [as 别名]
# 或者: from chaco.api.VPlotContainer import add [as 别名]
def _plot_default(self):
plotter = Plot(data=self.data)
main_plot = plotter.plot(['x','y'])[0]
self.configure_plot(main_plot, xlabel='')
plotter2 = Plot(data=self.data)
zoom_plot = plotter2.plot(['x','y'])[0]
self.configure_plot(zoom_plot)
plotter3 = Plot(data = self.data)
events_plot = plotter3.plot(['x','y'])[0]
self.configure_plot(events_plot)
outer_container = VPlotContainer(padding=20,
fill_padding=True,
spacing=0,
stack_order='top_to_bottom',
bgcolor='lightgray',
use_backbuffer=True)
outer_container.add(main_plot)
outer_container.add(zoom_plot)
outer_container.add(events_plot)
# FIXME: This is set to the windows bg color. Should get from the system.
#outer_container.bgcolor = (236/255., 233/255., 216/255., 1.0)
main_plot.controller = RangeSelection(main_plot)
zoom_overlay = ZoomOverlay(source=main_plot, destination=zoom_plot)
outer_container.overlays.append(zoom_overlay)
return outer_container
示例6: _create_plot_component
# 需要导入模块: from chaco.api import VPlotContainer [as 别名]
# 或者: from chaco.api.VPlotContainer import add [as 别名]
def _create_plot_component(obj):
# Setup the spectrum plot
frequencies = linspace(0.0, float(SAMPLING_RATE)/2, num=NUM_SAMPLES/2)
obj.spectrum_data = ArrayPlotData(frequency=frequencies)
empty_amplitude = zeros(NUM_SAMPLES/2)
obj.spectrum_data.set_data('amplitude', empty_amplitude)
obj.spectrum_plot = Plot(obj.spectrum_data)
spec_renderer = obj.spectrum_plot.plot(("frequency", "amplitude"), name="Spectrum",
color="red")[0]
obj.spectrum_plot.padding = 50
obj.spectrum_plot.title = "Spectrum"
spec_range = list(obj.spectrum_plot.plots.values())[0][0].value_mapper.range
spec_range.low = 0.0
spec_range.high = 5.0
obj.spectrum_plot.index_axis.title = 'Frequency (hz)'
obj.spectrum_plot.value_axis.title = 'Amplitude'
# Time Series plot
times = linspace(0.0, float(NUM_SAMPLES)/SAMPLING_RATE, num=NUM_SAMPLES)
obj.time_data = ArrayPlotData(time=times)
empty_amplitude = zeros(NUM_SAMPLES)
obj.time_data.set_data('amplitude', empty_amplitude)
obj.time_plot = Plot(obj.time_data)
obj.time_plot.plot(("time", "amplitude"), name="Time", color="blue")
obj.time_plot.padding = 50
obj.time_plot.title = "Time"
obj.time_plot.index_axis.title = 'Time (seconds)'
obj.time_plot.value_axis.title = 'Amplitude'
time_range = list(obj.time_plot.plots.values())[0][0].value_mapper.range
time_range.low = -0.2
time_range.high = 0.2
# Spectrogram plot
values = [zeros(NUM_SAMPLES/2) for i in range(SPECTROGRAM_LENGTH)]
p = WaterfallRenderer(index = spec_renderer.index, values = values,
index_mapper = LinearMapper(range = obj.spectrum_plot.index_mapper.range),
value_mapper = LinearMapper(range = DataRange1D(low=0, high=SPECTROGRAM_LENGTH)),
y2_mapper = LinearMapper(low_pos=0, high_pos=8,
range=DataRange1D(low=0, high=15)),
)
spectrogram_plot = p
obj.spectrogram_plot = p
dummy = Plot()
dummy.padding = 50
dummy.index_axis.mapper.range = p.index_mapper.range
dummy.index_axis.title = "Frequency (hz)"
dummy.add(p)
container = HPlotContainer()
container.add(obj.spectrum_plot)
container.add(obj.time_plot)
c2 = VPlotContainer()
c2.add(dummy)
c2.add(container)
return c2
示例7: test_halign
# 需要导入模块: from chaco.api import VPlotContainer [as 别名]
# 或者: from chaco.api.VPlotContainer import add [as 别名]
def test_halign(self):
container = VPlotContainer(bounds=[200,300], halign="center")
comp1 = StaticPlotComponent([100,200])
container.add(comp1)
container.do_layout()
self.assertEqual(comp1.position, [50,0])
container.halign="right"
container.do_layout(force=True)
self.assertEqual(comp1.position, [100,0])
return
示例8: ChacoReporter
# 需要导入模块: from chaco.api import VPlotContainer [as 别名]
# 或者: from chaco.api.VPlotContainer import add [as 别名]
class ChacoReporter(StateDataReporter, HasTraits):
plots = Instance(VPlotContainer)
labels = List
traits_view = View(
Group(Item('plots', editor=ComponentEditor(), show_label=False)),
width=800, height=600, resizable=True,
title='OpenMM')
def construct_plots(self):
"""Build the Chaco Plots. This will be run on the first report
"""
self.labels = super(ChacoReporter, self)._headers()
self.plots = VPlotContainer(resizable="hv", bgcolor="lightgray",
fill_padding=True, padding=10)
# this looks cryptic, but it is equivalent to
# ArrayPlotData(a=[], b=[], c=[])
# if the keys are a,b,c. This just does it for all of the keys.
self.plotdata = ArrayPlotData(**dict(zip(self.labels,
[[]]*len(self.labels))))
# figure out which key will be the x axis
x = None
x_labels = ['Time (ps)', 'Step']
for possible_x in x_labels:
if possible_x in self.labels:
x = possible_x
break
if x is None:
raise ValueError('The reporter published neither the step nor time'
'count, so I don\'t know what to plot on the x-axis!')
colors = itertools.cycle(['blue', 'green', 'silver', 'pink', 'lightblue',
'red', 'darkgray', 'lightgreen'])
for y in set(self.labels).difference(x_labels):
self.plots.add(chaco_scatter(self.plotdata, x_name=x, y_name=y,
color=colors.next()))
def _constructReportValues(self, simulation, state):
values = super(ChacoReporter, self)._constructReportValues(simulation, state)
for i, label in enumerate(self.labels):
current = self.plotdata.get_data(label)
self.plotdata.set_data(label, np.r_[current, float(values[i])])
return values
def report(self, simulation, state):
if not self._hasInitialized:
self.construct_plots()
super(ChacoReporter, self).report(simulation, state)
示例9: normal_left_dclick
# 需要导入模块: from chaco.api import VPlotContainer [as 别名]
# 或者: from chaco.api.VPlotContainer import add [as 别名]
def normal_left_dclick(self, event):
plot = Plot(self.data)
for data, kw in self.command_queue:
plot.plot(data, **kw)
plot.title = self.title
plot.title = self.title
container = VPlotContainer(bgcolor=WindowColor)
container.add(plot)
plot.tools.append(PanTool(plot))
plot.overlays.append(ZoomTool(plot))
window = PlotWindow(plot=container)
window.edit_traits(kind='live', parent=event.window.control)
示例10: test_stack_nonresize
# 需要导入模块: from chaco.api import VPlotContainer [as 别名]
# 或者: from chaco.api.VPlotContainer import add [as 别名]
def test_stack_nonresize(self):
container = VPlotContainer(bounds=[100,300])
comp1 = StaticPlotComponent([70,100])
comp2 = StaticPlotComponent([80,90])
comp3 = StaticPlotComponent([90,80])
container.add(comp1, comp2, comp3)
container.do_layout()
self.assert_tuple(container.get_preferred_size(), (90, 270))
self.assert_tuple(container.bounds, (100,300))
self.assert_tuple(comp1.position, (0,0))
self.assert_tuple(comp2.position, (0,100))
self.assert_tuple(comp3.position, (0,190))
return
示例11: _create_plot_component_vertical
# 需要导入模块: from chaco.api import VPlotContainer [as 别名]
# 或者: from chaco.api.VPlotContainer import add [as 别名]
def _create_plot_component_vertical(signals=Array,
use_downsampling=False):
# container = HPlotContainer(resizable = "hv", bgcolor="lightgray",
# fill_padding=True, padding = 10)
container = VPlotContainer(resizable="hv", bgcolor="lightgray",
fill_padding=True, padding=50)
nSignal, nSample = np.shape(signals)
time = arange(nSample)
value_range = None
plots = {}
for i in range(nSignal):
plot = create_line_plot((time, signals[i]),
color=tuple(COLOR_PALETTE[i % len(COLOR_PALETTE)]),
width=1.0,
# orientation="v")
orientation="h")
plot.origin_axis_visible = True
# plot.origin = "top left"
plot.padding_left = 10
plot.padding_right = 10
plot.border_visible = False
plot.bgcolor = "white"
if value_range is None:
value_range = plot.value_mapper.range
else:
plot.value_range = value_range
value_range.add(plot.value)
container.add(plot)
plots["Corr fun %d" % i] = plot
# Add a legend in the upper right corner, and make it relocatable
legend = Legend(component=plot, padding=10, align="ur")
legend.tools.append(LegendTool(legend, drag_button="right"))
plot.overlays.append(legend)
legend.plots = plots
# container.padding_top = 50
container.overlays.append(PlotLabel("Correlation function",
component=container,
font="swiss 16",
overlay_position="top"))
# selection_overlay = RangeSelectionOverlay(component=plot)
# plot.tools.append(RangeSelection(plot))
zoom = ZoomTool(plot, tool_mode="box", always_on=False)
# plot.overlays.append(selection_overlay)
plot.overlays.append(zoom)
return container
示例12: _composite_plot_default
# 需要导入模块: from chaco.api import VPlotContainer [as 别名]
# 或者: from chaco.api.VPlotContainer import add [as 别名]
def _composite_plot_default(self):
line_plot = Plot(self.plotdata)
line_plot.plot(('x', 'y'), type='line', color='blue')
img_plot = Plot(self.plotdata)
img_plot.img_plot("zdata",
xbounds='x_range',
ybounds='y_range',
colormap=jet)
cp = VPlotContainer()
cp.add(img_plot)
cp.add(line_plot)
return cp
示例13: test_stack_one_resize
# 需要导入模块: from chaco.api import VPlotContainer [as 别名]
# 或者: from chaco.api.VPlotContainer import add [as 别名]
def test_stack_one_resize(self):
"Checks stacking with 1 resizable component thrown in"
container = VPlotContainer(bounds=[100,300])
comp1 = StaticPlotComponent([70,100])
comp2 = StaticPlotComponent([80,90])
comp3 = StaticPlotComponent([90,80], resizable='hv')
comp4 = StaticPlotComponent([50,40])
container.add(comp1, comp2, comp3, comp4)
container.do_layout()
self.assert_tuple(container.get_preferred_size(), (80,230))
self.assert_tuple(container.bounds, (100,300))
self.assert_tuple(comp1.position, (0,0))
self.assert_tuple(comp2.position, (0,100))
self.assert_tuple(comp3.position, (0,190))
self.assert_tuple(comp4.position, (0,260))
return
示例14: _container_default
# 需要导入模块: from chaco.api import VPlotContainer [as 别名]
# 或者: from chaco.api.VPlotContainer import add [as 别名]
def _container_default(self):
plot = Plot(self.dataset)
plot.plot( ('dates', self.data_provider.code), type='line')
# Add tools
plot.tools.append(ZoomTool(plot))
plot.tools.append(PanTool(plot))
# Set the plot's bottom axis to use the Scales ticking system
ticker = ScalesTickGenerator(scale=CalendarScaleSystem())
plot.x_axis.tick_generator = ticker
container = VPlotContainer()
container.add(plot)
return container
示例15: test_fit_components
# 需要导入模块: from chaco.api import VPlotContainer [as 别名]
# 或者: from chaco.api.VPlotContainer import add [as 别名]
def test_fit_components(self):
container = VPlotContainer(bounds=[200,300], resizable="v", fit_components="v")
comp1 = StaticPlotComponent([50,100], padding=5)
comp2 = StaticPlotComponent([50,120], padding=5)
container.add(comp1)
container.add(comp2)
self.assert_tuple(container.get_preferred_size(), (200,240))
# The container should not change its size as a result of its fit_components
# being set.
self.assert_tuple(container.bounds, (200,300))
container.bounds = container.get_preferred_size()
container.do_layout()
container.padding = 8
self.assert_tuple(container.get_preferred_size(), (216,256))
container.do_layout()
self.assert_tuple(comp1.outer_position, (0,0))
self.assert_tuple(comp2.outer_position, (0,110))