Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def trait_view(self, view):
""" Build the view. The local namespace is
"""
return View(
VGroup(Item('data_file', style='simple', label="HDF file to load"),
HSplit(Item('ts_plot', editor=ComponentEditor(size=(400, 600)),
show_label=False),
VGroup(Item('tool_chooser', show_label = True, label="Choose tool"),
Item('ts1_chooser', label="TS 1"),
Item('ts2_chooser', label="TS 2",
visible_when="tool_chooser in ['%s']" % CORRELATION),
Item('ma_window_size', label="MA window size",
visible_when="tool_chooser in ['%s']" % MA),
Item('ts_analysis_plot', editor=ComponentEditor(size=(400, 600)),
show_label=False),
Item('ts_analysis_details', show_label = False, style = 'readonly',
visible_when=("tool_chooser in ['%s']" % CORRELATION))),),
),
title='Time-series plotter and analyzer',
width=1300, height=800, resizable=True)
title = "Basic scatter plot"
bg_color="lightgray"
#===============================================================================
# # Demo class that is used by the demo.py application.
#===============================================================================
class Demo(HasTraits):
plot = Instance(Component)
scatter_renderer = Instance(Component)
alpha = DelegatesTo('scatter_renderer')
traits_view = View(
Group(
Item('plot', editor=ComponentEditor(size=size,
bgcolor=bg_color),
show_label=False),
Group(
Item('alpha', editor=RangeEditor(low=0.0, high=1.0)),
),
orientation = "vertical"),
resizable=True, title=title
)
def _plot_default(self):
return _create_plot_component()
def _scatter_renderer_default(self):
renderer = _create_scatter_renderer(self.plot)
return renderer
return plot1
#===============================================================================
# Attributes to use for the plot view.
size=(900,500)
title="Multi-Y plot"
#===============================================================================
# # Demo class that is used by the demo.py application.
#===============================================================================
class Demo(HasTraits):
plot = Instance(Component)
traits_view = View(
Group(
Item('plot', editor=ComponentEditor(size=size),
show_label=False),
orientation = "vertical"),
resizable=True, title=title,
width=size[0], height=size[1]
)
def _plot_default(self):
return _create_plot_component()
demo = Demo()
if __name__ == "__main__":
demo.configure_traits()
#axis_traits_group=VGroup(
#HGroup(
#Item('x_axis_title'), Item('t_axis_title'), Item('plot_title'),
#),
#HGroup(
#Item('markersize'),Item('linestyle'),
#),
#)
#sample_group=Group(
#HGroup(Item('spacing'), Item('samp_style') )
#)
main_group=Group(
Item('plot', editor=ComponentEditor(), show_label=False),
# Item('df_new'), Item('df_change'),
Item('re_bin', style='simple'),
#Include('sample_group'),
#Include('axis_traits_group')
)
traits_view=View( Include('main_group') )
class WithShell(HasTraits):
df=Instance(DataFrame)
shell=Any()
plot=Instance(PandasPlot)
def __init__(self):
class ConnectionMatrixViewer(HasTraits):
tplot = Instance(Plot)
plot = Instance(Component)
custtool = Instance(CustomTool)
colorbar = Instance(ColorBar)
fro = Any
to = Any
data = None
val = Float
nodelabels = Any
traits_view = View(
Group(
Item('plot', editor=ComponentEditor(size=(800,600)),
show_label=False),
HGroup(
Item('fro', label="From", style = 'readonly', springy=True),
Item('to', label="To", style = 'readonly', springy=True),
Item('val', label="Value", style = 'readonly', springy=True),
),
orientation = "vertical"),
Item('data_name', label="Edge key"),
# handler=CustomHandler(),
resizable=True, title="Connection Matrix Viewer"
)
def __init__(self, nodelabels, matdict, **traits):
""" Starts a matrix inspector
plot.tools.append(highlight_tool)
class GSODDataPlotterView(HasTraits):
""" Application of the zoom tool to the GSOD plotting tool.
Load a HDF file containing one or more timeseries and plot the entire data inside.
The zoom tool allows to explore a subset of it. The legend allows to (de)select some
timeseries.
"""
data_file = File()
ts_data = Dict()
ts_plot = Instance(ToolbarPlot)
index_is_dates = Bool()
traits_view = View(
VGroup(Item('data_file', style = 'simple', label="HDF file to load"),
Item('ts_plot', editor=ComponentEditor(size=(800, 600)),
show_label=False),),
title='Chaco Plot with file loader and legend highlighter',
width=900, height=800, resizable=True)
def __init__(self, pandas_list = [], array_dict = {}, *args, **kw):
""" If a (list of) pandas or a dict of arrays is passed, load them up.
"""
ts_data = {}
super(GSODDataPlotterView, self).__init__(*args, **kw)
if not isinstance(pandas_list, list):
pandas_list = [pandas_list]
if pandas_list:
array_dict, self.index_is_dates = pandas2array_dict(pandas_list)
ts_data.update(array_dict)
if array_dict:
ts_data.update(ts_dict)
"""
info.object.timer.Stop()
return
class Demo(HasTraits):
plot = Instance(Component)
controller = Instance(TimerController, ())
timer = Instance(Timer)
traits_view = View(
Group(
Item('plot', editor=ComponentEditor(size=size),
show_label=False),
orientation = "vertical"),
resizable=True, title=title,
width=size[0], height=size[1],
handler=DemoHandler
)
def __init__(self, **traits):
super(Demo, self).__init__(**traits)
self.plot = _create_plot_component(self.controller)
def edit_traits(self, *args, **kws):
# Start up the timer! We should do this only when the demo actually
# starts and not when the demo object is created.
self.timer = Timer(20, self.controller.onTimer)
return super(Demo, self).edit_traits(*args, **kws)
fcpc = _fuel_cycle_plot_component(x, y, self.x_name, self.y_name)
self.plot = fcpc
# def update_x_path(self, node):
# print node.path
# self.x_path = node.path[1:].replace('/', '.')
x_node = Any
y_node = Any
traits_view = View(
HGroup(
Item('x_tree', editor = _hdf5_tree_editor(selected='x_node'), resizable = True, show_label=False, width=0.15),
Item('y_tree', editor = _hdf5_tree_editor(selected='y_node'), resizable = True, show_label=False, width=0.15),
Item('plot', editor=ComponentEditor(size=(700, 700), bgcolor='lightgray'), show_label=False),
),
resizable=True,
)
#
# Trait Defaults
#
def _plot_default(self):
fcpc = _fuel_cycle_plot_component(self.x, self.y, 'No Data', 'No Data')
return fcpc
def _h5file_default(self):
h5file = tb.openFile(self.file, 'r')
return h5file
# 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)
return plot
class ScatterPlotView(HasTraits):
plot = Instance(Component)
ind = Array
z = Array
traits_view = View(
Group(
Item('plot', editor=ComponentEditor(size=(500, 500),
bgcolor='lightgray'),
show_label=False),
orientation = "vertical"),
resizable=True,
)
def _z_changed(self, old, new):
print "z changed!"
self.ind = np.arange(len(self.z))
self.plot.plots['plot0'][0].index.set_data(self.ind)
self.plot.plots['plot0'][0].value.set_data(self.z)
def _plot_default(self):
self.ind = np.arange(len(self.z))
return _create_display_scatter_plot_component(self.ind, self.z)
from traits.api import HasTraits, Instance
from traitsui.api import View, UItem, Item, RangeEditor, Group, VGroup
from enable.api import ComponentEditor
from enable.gadgets.vu_meter import VUMeter
class Demo(HasTraits):
vu = Instance(VUMeter)
traits_view = View(
VGroup(
Group(
UItem('vu', editor=ComponentEditor(size=(60, 60)),
style='custom'),
),
Item('object.vu.percent',
editor=RangeEditor(low=0.0, high=200.0, mode='slider')),
),
'_',
VGroup(
Item('object.vu.angle', label="angle",
editor=RangeEditor(low=0.0, high=89.0, mode='slider')),
Item('object.vu._beta',
editor=RangeEditor(low=0.0, high=1.0, mode='slider')),
),
width=450,
height=380,
title="VU Meter",
resizable=True,