本文整理汇总了Python中enthought.chaco.api.VPlotContainer类的典型用法代码示例。如果您正苦于以下问题:Python VPlotContainer类的具体用法?Python VPlotContainer怎么用?Python VPlotContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VPlotContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _main_tab_default
def _main_tab_default(self):
self.sal_plot = Plot(self.plot_data)
self.sal_plot.plot(('time_ds', 'sal_ds'), type='line')
#sal_plot.overlays.append(PlotAxis(sal_plot, orientation='left'))
#bottom_axis = PlotAxis(sal_plot, orientation="bottom",# mapper=xmapper,
# tick_generator=ScalesTickGenerator(scale=CalendarScaleSystem()))
#sal_plot.overlays.append(bottom_axis)
#hgrid, vgrid = add_default_grids(sal_plot)
#vgrid.tick_generator = bottom_axis.tick_generator
#sal_plot.tools.append(PanTool(sal_plot, constrain=True,
# constrain_direction="x"))
#sal_plot.overlays.append(ZoomTool(sal_plot, drag_button="right",
# always_on=True,
# tool_mode="range",
# axis="index",
# max_zoom_out_factor=10.0,
# ))
container = VPlotContainer(bgcolor="lightblue",
spacing=40,
padding=50,
fill_padding=False)
container.add(sal_plot)
#container.add(price_plot)
#container.overlays.append(PlotLabel("Salinity Plot with Date Axis",
# component=container,
# #font="Times New Roman 24"))
# font="Arial 24"))
return container
示例2: _create_plot_component
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
示例3: create_zoomed_plot
def create_zoomed_plot():
try:
x,y = read_music_data()
except:
x = linspace(-10*pi, 10*pi, numpts)
y = sin(x)
main_plot = create_gridded_line_plot(x,y)
zoom_plot = create_gridded_line_plot(x,y)
outer_container = VPlotContainer(padding=30,
fill_padding=True,
spacing=50,
stack_order='top_to_bottom',
bgcolor='lightgray',
use_backbuffer=True)
outer_container.add(main_plot)
outer_container.add(zoom_plot)
main_plot.controller = RangeSelection(main_plot)
zoom_overlay = ZoomOverlay(source=main_plot, destination=zoom_plot)
outer_container.overlays.append(zoom_overlay)
return outer_container
示例4: _create_plot_component
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 = 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 = 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 xrange(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
示例5: _createResultsPane
def _createResultsPane(self):
container = VPlotContainer(resizable = "hv", bgcolor="lightgray", fill_padding=True, padding = 10)
#container = Container(resizable = "hv", bgcolor="lightgray", fill_padding=True, padding = 10)
addTitleOverlay(container, 'Results Pane')
container.add(self._createVoltageTraceComponent())
return container
示例6: _createConfigurationPane
def _createConfigurationPane(self):
container = VPlotContainer(resizable = "hv", bgcolor="lightgray", fill_padding=True, padding = 10)
#container = Container(resizable = "hv", bgcolor="lightgray", fill_padding=True, padding = 10)
addTitleOverlay(container, 'Configuration Pane')
container.add(self._create_cellConfigComponent())
container.add_trait ('self.surface_area_um2', self.surface_area_um2)
#traits_view = View(Item('self.surface_area_um2', editor=ComponentEditor(), show_label=False), width=500, height=500, resizable=True, title="Chaco Plot")
#container.add(traits_view)
return container
示例7: normal_left_dclick
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)
示例8: _create_plot_component
def _create_plot_component(self):
spectrum_plot = Plot(self.data)
spectrum_plot.plot(("frequency", "amplitude"), name="Spectrum", color=(1, 0, 0), line_width=2)
spectrum_plot.padding_bottom = 20
spectrum_plot.padding_top = 20
spectrum_plot.index_range.low = MIN_FREQUENCY
spectrum_plot.index_range.high = MAX_FREQUENCY
spec_range = spectrum_plot.plots.values()[0][0].value_mapper.range
spec_range.low = 0.0
spec_range.high = 65536.0
spectrum_plot.index_axis.title = 'Frequency(Hz)'
spectrum_plot.value_axis.title = 'Amplitude(dB)'
container = VPlotContainer()
container.add(spectrum_plot)
return container
示例9: __init__
def __init__(self):
# 首先需要调用父类的初始化函数
super(TriangleWave, self).__init__()
# 创建绘图数据集,暂时没有数据因此都赋值为空,只是创建几个名字,以供Plot引用
self.plot_data = ArrayPlotData(x=[], y=[], f=[], p=[], x2=[], y2=[])
# 创建一个垂直排列的绘图容器,它将频谱图和波形图上下排列
self.container = VPlotContainer()
# 创建波形图,波形图绘制两条曲线: 原始波形(x,y)和合成波形(x2,y2)
self.plot_wave = self._create_plot(("x", "y"), "Triangle Wave")
self.plot_wave.plot(("x2", "y2"), color="red")
# 创建频谱图,使用数据集中的f和p
self.plot_fft = self._create_plot(("f", "p"), "FFT", type="scatter")
# 将两个绘图容器添加到垂直容器中
self.container.add(self.plot_wave)
self.container.add(self.plot_fft)
# 设置
self.plot_wave.x_axis.title = "Samples"
self.plot_fft.x_axis.title = "Frequency pins"
self.plot_fft.y_axis.title = "(dB)"
# 改变fftsize为1024,因为Enum的默认缺省值为枚举列表中的第一个值
self.fftsize = 1024
示例10: _field_data_plots_default
def _field_data_plots_default(self):
# Plot data and vertical container object
data = ArrayPlotData(**self._get_field_plots_data())
container = VPlotContainer()
# Add individual distributions plots to container
for key in ('area', 'diameter', 'average', 'peak'):
p = Plot(data)
p.plot((key+'_bins', key), name=key, type='polygon', edge_width=2,
edge_color='red', face_color='salmon')
p.x_axis.title = key
p.y_axis.title = 'count'
p.padding = [50, 30, 20, 40]
container.add(p)
return container
示例11: test_halign
def test_halign(self):
container = VPlotContainer(bounds=[200,300], halign="center")
comp1 = StaticPlotComponent([100,200])
container.add(comp1)
container.do_layout()
self.failUnlessEqual(comp1.position, [50,0])
container.halign="right"
container.do_layout(force=True)
self.failUnlessEqual(comp1.position, [100,0])
return
示例12: _create_plot_component
def _create_plot_component(self):
self.data = ArrayPlotData()
self.data["frequency"] = np.linspace(0., SAMPLING_RATE/2.0, num=NUM_SAMPLES/2)
for i in xrange(NUM_LINES):
self.data['amplitude%d' % i] = np.zeros(NUM_SAMPLES/2)
self.data["time"] = np.linspace(0., float(NUM_SAMPLES)/SAMPLING_RATE, num=NUM_SAMPLES)
self.data['time_amplitude'] = np.zeros(NUM_SAMPLES)
self.data['imagedata'] = np.zeros(( NUM_SAMPLES/2, SPECTROGRAM_LENGTH))
spectrum_plot = Plot(self.data)
for i in xrange(NUM_LINES):
if i==NUM_LINES-1:
linewidth = 2
color = (1,0,0)
else:
linewidth = 1
c = (NUM_LINES-i-1)/float(NUM_LINES)
color = (1, 0.5+c/2, c)
spectrum_plot.plot(("frequency", "amplitude%d" % i), name="Spectrum%d" % i,
color=color, line_width=linewidth)
spectrum_plot.padding_bottom = 20
spectrum_plot.padding_top = 20
spec_range = spectrum_plot.plots.values()[0][0].value_mapper.range
spec_range.low = -90
spec_range.high = 0.0
spectrum_plot.index_axis.title = 'Frequency(Hz)'
spectrum_plot.value_axis.title = 'Amplitude(dB)'
time_plot = Plot(self.data)
time_plot.plot(("time", "time_amplitude"), name="Time", color="blue")
time_plot.padding_top = 20
time_plot.padding_bottom = 20
time_plot.index_axis.title = 'Time (seconds)'
time_plot.value_axis.title = 'Amplitude'
time_range = time_plot.plots.values()[0][0].value_mapper.range
time_range.low = -1.5
time_range.high = 1.5
spectrogram_plot = Plot(self.data)
spectrogram_time = (0.0, SPECTROGRAM_LENGTH*NUM_SAMPLES/float(SAMPLING_RATE))
spectrogram_freq = (0.0, SAMPLING_RATE/2.0)
spectrogram_plot.img_plot('imagedata',
name='Spectrogram',
xbounds=spectrogram_time,
ybounds=spectrogram_freq,
colormap=cm.reverse(cm.Blues),
)
range_obj = spectrogram_plot.plots['Spectrogram'][0].value_mapper.range
range_obj.high = -20
range_obj.low = -60
spectrogram_plot.padding_bottom = 20
spectrogram_plot.padding_top = 20
container = VPlotContainer()
container.add(time_plot)
container.add(spectrum_plot)
container.add(spectrogram_plot)
return container
示例13: _create_window
def _create_window(self):
# 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.01, 0.1, size=numpoints)
price = 100.0 * cumprod(returns)
volume = abs(random.normal(1000.0, 1500.0, size=numpoints) + 2000.0)
time_ds = ArrayDataSource(index)
vol_ds = ArrayDataSource(volume, sort_order="none")
price_ds = ArrayDataSource(price, sort_order="none")
# Create the price plots
price_plot, mini_plot = self._create_price_plots(time_ds, price_ds)
price_plot.index_mapper.domain_limits = (index[0], index[-1])
self.price_plot = price_plot
self.mini_plot = mini_plot
# Create the volume plot
vol_plot = self._create_vol_plot(time_ds, vol_ds)
vol_plot.index_mapper.domain_limits = (index[0], index[-1])
# Set the plot's bottom axis to use the Scales ticking system
ticker = ScalesTickGenerator(scale=CalendarScaleSystem())
for plot in price_plot, mini_plot, vol_plot:
bottom_axis = PlotAxis(plot, orientation="bottom",
tick_generator = ticker)
plot.overlays.append(bottom_axis)
plot.overlays.append(PlotAxis(plot, orientation="left"))
hgrid, vgrid = add_default_grids(plot)
vgrid.tick_generator = bottom_axis.tick_generator
container = VPlotContainer(bgcolor = "lightgray",
spacing = 40,
padding = 50,
fill_padding=False)
container.add(mini_plot, vol_plot, price_plot)
return Window(self, -1, component=container)
示例14: _unit_data_plots_default
def _unit_data_plots_default(self):
# Plot data and vertical container object
data = ArrayPlotData(**self._get_unit_plots_data())
container = VPlotContainer()
# Add individual distribution plots to container
for key in ('avg_diameter', 'avg_area', 'coverage', 'max_r', 'num_fields'):
p = Plot(data)
p.plot((key+'_bins', key), name=key, type='polygon', edge_width=2,
edge_color='mediumblue', face_color='lightsteelblue')
p.x_axis.title = key
p.y_axis.title = 'count'
p.padding = [50, 30, 20, 40]
if key == 'num_fields':
p.x_axis.tick_interval = 1
container.add(p)
return container
示例15: __init__
def __init__(self):
super(EqualizerDesigner, self).__init__()
self.plot_data = ArrayPlotData(f=FREQS, gain=[], phase=[])
self.plot_gain = self._create_plot(("f", "gain"), "Gain(dB)")
self.plot_phase = self._create_plot(("f", "phase"), "Phase(degree)")
self.container = VPlotContainer()
self.container.add( self.plot_phase )
self.container.add( self.plot_gain )
self.plot_gain.padding_bottom = 20
self.plot_phase.padding_top = 20