本文整理汇总了Python中enthought.chaco.api.HPlotContainer.add方法的典型用法代码示例。如果您正苦于以下问题:Python HPlotContainer.add方法的具体用法?Python HPlotContainer.add怎么用?Python HPlotContainer.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enthought.chaco.api.HPlotContainer
的用法示例。
在下文中一共展示了HPlotContainer.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer import add [as 别名]
def draw( self ):
"""Draw data."""
if len(self.fitResults) == 0:
return
#if not hasattr( self, 'subplot1' ):
# self.subplot1 = self.figure.add_subplot( 211 )
# self.subplot2 = self.figure.add_subplot( 212 )
a, ed = numpy.histogram(self.fitResults['tIndex'], self.Size[0]/2)
#self.subplot1.cla()
#self.subplot1.plot(ed[:-1], a, color='b' )
#self.subplot1.set_xticks([0, ed.max()])
#self.subplot1.set_yticks([0, a.max()])
#self.subplot2.cla()
#self.subplot2.plot(ed[:-1], numpy.cumsum(a), color='g' )
#self.subplot2.set_xticks([0, ed.max()])
#self.subplot2.set_yticks([0, a.sum()])
plot1 = create_line_plot(ed[:,-1], a, color = 'blue', bgcolor="white",
add_grid=True, add_axis=True)
plot2 = create_line_plot(ed[:,-1], numpy.cumsum(a), color = 'green', bgcolor="white",
add_grid=True, add_axis=True)
container = HPlotContainer(spacing=20, padding=50, bgcolor="lightgray")
container.add(plot1)
container.add(plot2)
return container
示例2: _create_plot_component
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer 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, title="Line Plot", padding=50, border_visible=True)
plot1.legend.visible = True
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)
# Create a second scatter plot of one of the datasets, linking its
# range to the first plot
plot2 = Plot(pd, range2d=plot1.range2d, title="Scatter plot", padding=50,
border_visible=True)
plot2.plot(('index', 'y3'), type="scatter", color="blue", marker="circle")
# Create a container and add our plots
container = HPlotContainer()
container.add(plot1)
container.add(plot2)
return container
示例3: _create_plot_component
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer import add [as 别名]
def _create_plot_component():
# Create some x-y data series to plot
x = linspace(-2.0, 10.0, 40)
pd = ArrayPlotData(index = x, y0=jn(0,x))
# Create some line plots of some of the data
plot1 = Plot(pd, title="render_style = hold", padding=50, border_visible=True,
overlay_border = True)
plot1.legend.visible = True
lineplot = plot1.plot(("index", "y0"), name="j_0", color="red", render_style="hold")
# Attach some tools to the plot
attach_tools(plot1)
# Create a second scatter plot of one of the datasets, linking its
# range to the first plot
plot2 = Plot(pd, range2d=plot1.range2d, title="render_style = connectedhold",
padding=50, border_visible=True, overlay_border=True)
plot2.plot(('index', 'y0'), color="blue", render_style="connectedhold")
attach_tools(plot2)
# Create a container and add our plots
container = HPlotContainer()
container.add(plot1)
container.add(plot2)
return container
示例4: _create_plot_component
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer import add [as 别名]
def _create_plot_component():
numpoints = 100
low = -5
high = 15.0
x = arange(low, high, (high - low) / numpoints)
container = HPlotContainer(resizable="hv", bgcolor="lightgray", fill_padding=True, padding=10)
# container = VPlotContainer(resizable = "hv", bgcolor="lightgray",
# fill_padding=True, padding = 10)
# Plot some bessel functions
value_range = None
for i in range(10):
y = jn(i, x)
plot = create_line_plot((x, y), color=tuple(COLOR_PALETTE[i]), width=2.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 = True
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)
if i % 2 == 1:
plot.line_style = "dash"
container.add(plot)
container.padding_top = 50
container.overlays.append(PlotLabel("More Bessels", component=container, font="swiss 16", overlay_position="top"))
return container
示例5: _create_plot_component
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer import add [as 别名]
def _create_plot_component():
# Create some data
numpts = 1000
x = sort(random(numpts))
y = random(numpts)
color = exp(-(x**2 + y**2))
# Create a plot data obect and give it this data
pd = ArrayPlotData()
pd.set_data("index", x)
pd.set_data("value", y)
pd.set_data("color", color)
# Create the plot
plot = Plot(pd)
plot.plot(("index", "value", "color"),
type="cmap_scatter",
name="my_plot",
color_mapper=jet,
marker = "square",
fill_alpha = 0.5,
marker_size = 6,
outline_color = "black",
border_visible = True,
bgcolor = "white")
# Tweak some of the plot properties
plot.title = "Colormapped Scatter Plot"
plot.padding = 50
plot.x_grid.visible = False
plot.y_grid.visible = False
plot.x_axis.font = "modern 16"
plot.y_axis.font = "modern 16"
# Right now, some of the tools are a little invasive, and we need the
# actual ColomappedScatterPlot object to give to them
cmap_renderer = plot.plots["my_plot"][0]
# Attach some tools to the plot
plot.tools.append(PanTool(plot, constrain_key="shift"))
zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
plot.overlays.append(zoom)
selection = ColormappedSelectionOverlay(cmap_renderer, fade_alpha=0.35,
selection_type="mask")
cmap_renderer.overlays.append(selection)
# Create the colorbar, handing in the appropriate range and colormap
colorbar = create_colorbar(plot.color_mapper)
colorbar.plot = cmap_renderer
colorbar.padding_top = plot.padding_top
colorbar.padding_bottom = plot.padding_bottom
# Create a container to position the plot and the colorbar side-by-side
container = HPlotContainer(use_backbuffer = True)
container.add(plot)
container.add(colorbar)
container.bgcolor = "lightgray"
return container
示例6: _create_plot_component
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer 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
示例7: get_plot
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer import add [as 别名]
def get_plot(self):
pixel_sizes = self.data_source.voxel_sizes
shape = self.data.shape
m = min(pixel_sizes)
s = [int(d*sz/m) for d, sz in zip(shape, pixel_sizes)]
if 1: # else physical aspect ratio is enabled
ss = max(s)/4
s = [max(s,ss) for s in s]
plot_sizes = dict (xy = (s[2], s[1]), xz = (s[2], s[0]), zy = (s[0],s[1]), zz=(s[0],s[0]))
plots = GridContainer(shape=(2,2), spacing=(3, 3), padding = 50, aspect_ratio=1)
pxy = Plot(self.plotdata, padding=1, fixed_preferred_size = plot_sizes['xy'],
x_axis=PlotAxis (orientation='top'),
)
pxz = Plot(self.plotdata, padding=1, fixed_preferred_size = plot_sizes['xz'],
)
pzy = Plot(self.plotdata, padding=1, fixed_preferred_size = plot_sizes['zy'],
#orientation = 'v', # cannot use 'v' because of img_plot assumes row-major ordering
x_axis=PlotAxis(orientation='top'),
y_axis=PlotAxis(orientation='right'),
)
pzz = Plot(self.plotdata, padding=1, fixed_preferred_size = plot_sizes['zz'])
plots.add(pxy, pzy, pxz, pzz)
self.plots = dict(xy = pxy.img_plot('xy', colormap=bone)[0],
xz = pxz.img_plot('xz', colormap=bone)[0],
zy = pzy.img_plot('zy', colormap=bone)[0],
zz = pzz.img_plot('zz')[0],
xyp = pxy.plot(('z_x', 'z_y'), type='scatter', color='orange', marker='circle', marker_size=3,
selection_marker_size = 3, selection_marker='circle')[0],
xzp = pxz.plot(('y_x', 'y_z'), type='scatter', color='orange', marker='circle', marker_size=3,
selection_marker_size = 3, selection_marker='circle')[0],
zyp = pzy.plot(('x_z', 'x_y'), type='scatter', color='orange', marker='circle', marker_size=3,
selection_marker_size = 3, selection_marker='circle')[0],
)
for p in ['xy', 'xz', 'zy']:
self.plots[p].overlays.append(ZoomTool(self.plots[p]))
self.plots[p].tools.append(PanTool(self.plots[p], drag_button='right'))
imgtool = ImageInspectorTool(self.plots[p])
self.plots[p].tools.append(imgtool)
overlay = ImageInspectorOverlay(component=self.plots[p],
bgcolor = 'white',
image_inspector=imgtool)
self.plots['zz'].overlays.append(overlay)
self.plots[p+'p'].tools.append (ScatterInspector(self.plots[p+'p'], selection_mode = 'toggle'))
self.plots['xyp'].index.on_trait_change (self._xyp_metadata_handler, 'metadata_changed')
self.plots['xzp'].index.on_trait_change (self._xzp_metadata_handler, 'metadata_changed')
self.plots['zyp'].index.on_trait_change (self._zyp_metadata_handler, 'metadata_changed')
plot = HPlotContainer()
# todo: add colormaps
plot.add(plots)
return plot
示例8: _createWindow
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer import add [as 别名]
def _createWindow(self):
container = HPlotContainer(resizable = "hv", bgcolor="lightgray",
#container = Container(resizable = "hv", bgcolor="lightgray",
fill_padding=True, padding = 10)
container.add(self._createConfigurationPane())
container.add(self._createResultsPane())
#container.add(self._create_plot_component())
return container
示例9: test_valign
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer import add [as 别名]
def test_valign(self):
container = HPlotContainer(bounds=[300,200], valign="center")
comp1 = StaticPlotComponent([200,100])
container.add(comp1)
container.do_layout()
self.failUnlessEqual(comp1.position, [0,50])
container.valign="top"
container.do_layout(force=True)
self.failUnlessEqual(comp1.position, [0,100])
return
示例10: _create_plot_component
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer 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: test_stack_nonresize
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer import add [as 别名]
def test_stack_nonresize(self):
# Assuming resizable='' for all plot containers and components
container = HPlotContainer(bounds=[300,100])
comp1 = StaticPlotComponent([100,70])
comp2 = StaticPlotComponent([90,80])
comp3 = StaticPlotComponent([80,90])
container.add(comp1, comp2, comp3)
container.do_layout()
self.assert_tuple(container.get_preferred_size(), (270,90))
self.assert_tuple(container.bounds, (300,100))
self.assert_tuple(comp1.position, (0,0))
self.assert_tuple(comp2.position, (100,0))
self.assert_tuple(comp3.position, (190,0))
return
示例12: _create_plot_component
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer 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
plot = Plot(pd, title="Line Plot", padding=50, border_visible=True)
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.x_grid.line_color = "black"
plot.y_grid.line_color = "black"
xmin, xmax = 1.0, 6.0
ymin, ymax = 0.2, 0.80001
plot.x_grid.set(data_min = xmin, data_max = xmax,
transverse_bounds = (ymin, ymax),
transverse_mapper = plot.y_mapper)
plot.y_grid.set(data_min = ymin, data_max = ymax,
transverse_bounds = (xmin, xmax),
transverse_mapper = plot.x_mapper)
# Attach some tools to the plot
plot.tools.append(PanTool(plot))
zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
plot.overlays.append(zoom)
# A second plot whose vertical grid lines are clipped to the jn(3) function
def my_bounds_func(ticks):
""" Returns y_low and y_high for each grid tick in the array **ticks** """
tmp = array([zeros(len(ticks)),jn(3, ticks)]).T
return tmp
func_plot = Plot(pd, padding=50, border_visible=True)
func_plot.plot(("index", "y3"), color="red")
func_plot.x_grid.set(transverse_bounds = my_bounds_func,
transverse_mapper = func_plot.y_mapper,
line_color="black")
func_plot.tools.append(PanTool(func_plot))
container = HPlotContainer()
container.add(plot)
container.add(func_plot)
return container
示例13: test_stack_one_resize
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer import add [as 别名]
def test_stack_one_resize(self):
"Checks stacking with 1 resizable component thrown in"
container = HPlotContainer(bounds=[300,100])
comp1 = StaticPlotComponent([100,70])
comp2 = StaticPlotComponent([90,80])
comp3 = StaticPlotComponent([80,90], resizable='hv')
comp4 = StaticPlotComponent([40,50])
container.add(comp1, comp2, comp3, comp4)
container.do_layout()
self.assert_tuple(container.get_preferred_size(), (230,80))
self.assert_tuple(container.bounds, (300,100))
self.assert_tuple(comp1.position, (0,0))
self.assert_tuple(comp2.position, (100,0))
self.assert_tuple(comp3.position, (190,0))
self.assert_tuple(comp4.position, (260,0))
return
示例14: _create_plot_component
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer import add [as 别名]
def _create_plot_component():
# Create the index
numpoints = 100
low = -5
high = 15.0
x = arange(low, high, (high-low)/numpoints)
plotdata = ArrayPlotData(x=x, y1=jn(0,x), y2=jn(1,x))
# Create the left plot
left_plot = Plot(plotdata)
left_plot.x_axis.title = "X"
left_plot.y_axis.title = "j0(x)"
renderer = left_plot.plot(("x", "y1"), type="line", color="blue",
width=2.0)[0]
renderer.overlays.append(LineInspector(renderer, axis='value',
write_metadata=True,
is_listener=True))
renderer.overlays.append(LineInspector(renderer, axis="index",
write_metadata=True,
is_listener=True))
left_plot.overlays.append(ZoomTool(left_plot, tool_mode="range"))
left_plot.tools.append(PanTool(left_plot))
# Create the right plot
right_plot = Plot(plotdata)
right_plot.index_range = left_plot.index_range
right_plot.orientation = "v"
right_plot.x_axis.title = "j1(x)"
right_plot.y_axis.title = "X"
renderer2 = right_plot.plot(("x","y2"), type="line", color="red", width=2.0)[0]
renderer2.index = renderer.index
renderer2.overlays.append(LineInspector(renderer2, write_metadata=True, is_listener=True))
renderer2.overlays.append(LineInspector(renderer2, axis="value", is_listener=True))
right_plot.overlays.append(ZoomTool(right_plot, tool_mode="range"))
right_plot.tools.append(PanTool(right_plot))
container = HPlotContainer(background="lightgray")
container.add(left_plot)
container.add(right_plot)
return container
示例15: _create_window
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer import add [as 别名]
def _create_window(self):
# 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, title="Line Plot", padding=50, border_visible=True,
overlay_border=True)
plot1.legend.visible = True
plot1.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="red")
plot1.plot(("index", "y3"), name="j_3", color="blue")
# Create a container and add our plots
container = HPlotContainer()
container.add(plot1)
# Return a window containing our plots
return Window(self, -1, component=container)