本文整理匯總了Python中enthought.chaco.api.VPlotContainer.add方法的典型用法代碼示例。如果您正苦於以下問題:Python VPlotContainer.add方法的具體用法?Python VPlotContainer.add怎麽用?Python VPlotContainer.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類enthought.chaco.api.VPlotContainer
的用法示例。
在下文中一共展示了VPlotContainer.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _create_plot_component
# 需要導入模塊: from enthought.chaco.api import VPlotContainer [as 別名]
# 或者: from enthought.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
示例2: create_zoomed_plot
# 需要導入模塊: from enthought.chaco.api import VPlotContainer [as 別名]
# 或者: from enthought.chaco.api.VPlotContainer import add [as 別名]
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
示例3: _main_tab_default
# 需要導入模塊: from enthought.chaco.api import VPlotContainer [as 別名]
# 或者: from enthought.chaco.api.VPlotContainer import add [as 別名]
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
示例4: _create_plot_component
# 需要導入模塊: from enthought.chaco.api import VPlotContainer [as 別名]
# 或者: from enthought.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 = 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
# 需要導入模塊: from enthought.chaco.api import VPlotContainer [as 別名]
# 或者: from enthought.chaco.api.VPlotContainer import add [as 別名]
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: test_halign
# 需要導入模塊: from enthought.chaco.api import VPlotContainer [as 別名]
# 或者: from enthought.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.failUnlessEqual(comp1.position, [50,0])
container.halign="right"
container.do_layout(force=True)
self.failUnlessEqual(comp1.position, [100,0])
return
示例7: _createConfigurationPane
# 需要導入模塊: from enthought.chaco.api import VPlotContainer [as 別名]
# 或者: from enthought.chaco.api.VPlotContainer import add [as 別名]
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
示例8: test_stack_nonresize
# 需要導入模塊: from enthought.chaco.api import VPlotContainer [as 別名]
# 或者: from enthought.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
示例9: normal_left_dclick
# 需要導入模塊: from enthought.chaco.api import VPlotContainer [as 別名]
# 或者: from enthought.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: _create_plot_component
# 需要導入模塊: from enthought.chaco.api import VPlotContainer [as 別名]
# 或者: from enthought.chaco.api.VPlotContainer import add [as 別名]
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
示例11: test_stack_one_resize
# 需要導入模塊: from enthought.chaco.api import VPlotContainer [as 別名]
# 或者: from enthought.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
示例12: _field_data_plots_default
# 需要導入模塊: from enthought.chaco.api import VPlotContainer [as 別名]
# 或者: from enthought.chaco.api.VPlotContainer import add [as 別名]
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
示例13: test_fit_components
# 需要導入模塊: from enthought.chaco.api import VPlotContainer [as 別名]
# 或者: from enthought.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))
示例14: _create_window
# 需要導入模塊: from enthought.chaco.api import VPlotContainer [as 別名]
# 或者: from enthought.chaco.api.VPlotContainer import add [as 別名]
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)
示例15: _unit_data_plots_default
# 需要導入模塊: from enthought.chaco.api import VPlotContainer [as 別名]
# 或者: from enthought.chaco.api.VPlotContainer import add [as 別名]
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