本文整理汇总了Python中chaco.api.VPlotContainer类的典型用法代码示例。如果您正苦于以下问题:Python VPlotContainer类的具体用法?Python VPlotContainer怎么用?Python VPlotContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VPlotContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_plot_component
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: _plot_default
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
示例3: create_vplot
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()
示例4: __init__
def __init__(self):
super(HHCurrentTraits, self).__init__()
# gates
self.vm = linspace(-120,65,1000)
(M, N, H) = self.__gates()
nA = self.__iv()
self.gatedata = ArrayPlotData(x=self.vm, M=M, N=N, H=H)
self.ivdata = ArrayPlotData(x=self.vm, nA=nA)
gateplot = Plot(self.gatedata)
gateplot.plot(("x", "M"), type = "line", color = "blue")
gateplot.plot(("x", "N"), type = "line", color = "green")
gateplot.plot(("x", "H"), type = "line", color = "red")
ivplot = Plot(self.ivdata)
ivplot.plot(("x", "nA"), type = "line", color = "black")
container = VPlotContainer(ivplot, gateplot)
container.spacing = 0
gateplot.x_axis.orientation = "top"
gateplot.padding_bottom = 0
ivplot.padding_top = 0
self.plots = container
示例5: WaveformDisplay
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)
示例6: _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
示例7: _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 = 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
示例8: ChacoReporter
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
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_vertical
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
示例11: _composite_plot_default
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
示例12: _container_default
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
示例13: construct_plots
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()))
示例14: create_plots
def create_plots(self, keys):
"""Create the plots
Paramters
---------
keys : list of strings
A list of all of the keys in the msg dict. This should be something
like ['Step', 'Temperature', 'Potential Energy']. We'll create the
ArrayPlotData container in which each of these timeseries will
get put.
"""
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(keys, [[]]*len(keys))))
# figure out which key will be the x axis
if 'Step' in keys:
x = 'Step'
elif 'Time (ps)' in keys:
x = 'Time (ps)'
else:
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 filter(lambda y: y != x, keys):
self.plots.add(chaco_scatter(self.plotdata, x_name=x, y_name=y,
color=colors.next()))
示例15: __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