本文整理汇总了Python中enthought.chaco.api.HPlotContainer类的典型用法代码示例。如果您正苦于以下问题:Python HPlotContainer类的具体用法?Python HPlotContainer怎么用?Python HPlotContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HPlotContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_plot_component
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
示例2: draw
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
示例3: _create_plot_component
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
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
示例5: _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
示例6: get_plot
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
示例7: _createWindow
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
示例8: _create_plot_component
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
示例9: _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
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
示例10: test_valign
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
示例11: _create_plot_component
def _create_plot_component(obj):
# Setup the spectrum plot
frequencies = linspace(0.0, MAX_FREQ, num=MAX_FREQN)
obj.spectrum_data = ArrayPlotData(frequency=frequencies)
empty_amplitude = zeros(MAX_FREQN)
obj.spectrum_data.set_data("amplitude", empty_amplitude)
obj.spectrum_plot = Plot(obj.spectrum_data)
obj.spectrum_plot.plot(("frequency", "amplitude"), name="Spectrum", color="red")
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 = 150.0 # spectrum amplitude maximum
obj.spectrum_plot.index_axis.title = "Frequency (hz)"
obj.spectrum_plot.value_axis.title = "Amplitude"
# Time Series plot
times = linspace(0.0, float(TIME_NUM_SAMPLES) / SAMPLING_RATE, num=TIME_NUM_SAMPLES)
obj.time_data = ArrayPlotData(time=times)
empty_amplitude = zeros(TIME_NUM_SAMPLES)
obj.time_data.set_data("amplitude", empty_amplitude)
obj.time_data.set_data("amplitude_1", empty_amplitude)
obj.time_plot = Plot(obj.time_data)
obj.time_plot.plot(("time", "amplitude"), name="Time", color="blue", alpha=0.5)
obj.time_plot.plot(("time", "amplitude_1"), name="Time", color="red", alpha=0.5)
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 = -1
time_range.high = 1
# Spectrogram plot
spectrogram_data = zeros((MAX_FREQN, SPECTROGRAM_LENGTH))
obj.spectrogram_plotdata = ArrayPlotData()
obj.spectrogram_plotdata.set_data("imagedata", spectrogram_data)
spectrogram_plot = Plot(obj.spectrogram_plotdata)
max_time = float(SPECTROGRAM_LENGTH * NUM_SAMPLES) / SAMPLING_RATE
# max_freq = float(SAMPLING_RATE / 2)
max_freq = float(MAX_FREQ)
spectrogram_plot.img_plot(
"imagedata", name="Spectrogram", xbounds=(0, max_time), ybounds=(0, max_freq), colormap=jet
)
range_obj = spectrogram_plot.plots["Spectrogram"][0].value_mapper.range
range_obj.high = 2 # brightness of specgram
range_obj.low = 0.0
range_obj.edit_traits()
spectrogram_plot.title = "Spectrogram"
obj.spectrogram_plot = spectrogram_plot
container = HPlotContainer()
container.add(obj.spectrum_plot)
container.add(obj.time_plot)
container.add(spectrogram_plot)
return container
示例12: _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)
obj.spectrum_plot.plot(("frequency", "amplitude"), name="Spectrum",
color="red")
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
spectrogram_data = zeros(( NUM_SAMPLES/2, SPECTROGRAM_LENGTH))
obj.spectrogram_plotdata = ArrayPlotData()
obj.spectrogram_plotdata.set_data('imagedata', spectrogram_data)
spectrogram_plot = Plot(obj.spectrogram_plotdata)
max_time = float(SPECTROGRAM_LENGTH * NUM_SAMPLES) / SAMPLING_RATE
max_freq = float(SAMPLING_RATE / 2)
spectrogram_plot.img_plot('imagedata',
name='Spectrogram',
xbounds=(0, max_time),
ybounds=(0, max_freq),
colormap=jet,
)
range_obj = spectrogram_plot.plots['Spectrogram'][0].value_mapper.range
range_obj.high = 5
range_obj.low = 0.0
spectrogram_plot.title = 'Spectrogram'
obj.spectrogram_plot = spectrogram_plot
container = HPlotContainer()
container.add(obj.spectrum_plot)
container.add(obj.time_plot)
container.add(spectrogram_plot)
return container
示例13: __init__
def __init__(self):
# Create the data and the PlotData object
x = linspace(-14, 14, 100)
y = sin(x) * x**3
plotdata = ArrayPlotData(x = x, y = y)
# Create the scatter plot
scatter = Plot(plotdata)
scatter.plot(("x", "y"), type="scatter", color="blue")
# Create the line plot
line = Plot(plotdata)
line.plot(("x", "y"), type="line", color="blue")
# Create a horizontal container and put the two plots inside it
container = HPlotContainer(scatter, line)
container.spacing = 0
scatter.padding_right = 0
line.padding_left = 0
line.y_axis.orientation = "right"
self.plot = container
示例14: _create_plot_component
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
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)