Beispiel #1
0
def runmain():
    try:
        demo_main(PlotFrame, size=size, title=title)
    finally:
        if _stream is not None:
            _stream.close()
        if _wavefd is not None:
            _wavefd.close()
Beispiel #2
0
#===============================================================================
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
                    )

    def _plot_default(self):
         return _create_plot_component()

demo = Demo()

#===============================================================================
# Stand-alone frame to display the plot.
#===============================================================================
class PlotFrame(DemoFrame):

    def _create_window(self):
        # Return a window containing our plots
        return Window(self, -1, component=_create_plot_component())

if __name__ == "__main__":
    demo_main(PlotFrame, size=size, title=title)

#--EOF---
Beispiel #3
0
class MyFrame(DemoFrame):
    def _create_window(self):
        ts = touchstone.read('tests/data/deemb_mom.s2p')
        freqs = ts.freqs
        s11 = ts.get_parameter(1, 1)

        container = OverlayPlotContainer(padding=50,
                                         fill_padding=True,
                                         bgcolor="lightgray",
                                         use_backbuffer=True)

        plot = create_smith_plot((freqs, s11),
                                 color=(0.0, 0.0, 1.0, 1),
                                 width=2.0)
        plot.bgcolor = "white"
        container.add(plot)

        # Add the title at the top
        container.overlays.append(
            PlotLabel("Smith Chart",
                      component=container,
                      font="swiss 16",
                      overlay_position="top"))

        return Window(self, -1, component=container)


if __name__ == "__main__":
    demo_main(MyFrame, size=(600, 600), title="Simple Smith Chart")
Beispiel #4
0
        # 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)

if __name__ == "__main__":
    demo_main(PlotFrame, size=(800,600), title="Stock price and volume")
Beispiel #5
0
# Smith imports
from smith.create_smith_plot import create_smith_plot


class MyFrame(DemoFrame):
    def _create_window(self):
        ts = touchstone.read('tests/data/deemb_mom.s2p')
        freqs = ts.freqs
        s11 = ts.get_parameter(1 ,1)

        container = OverlayPlotContainer(padding=50, fill_padding=True,
                                         bgcolor="lightgray",
                                         use_backbuffer=True)

        plot = create_smith_plot((freqs, s11), color=(0.0, 0.0, 1.0, 1),
                                 width=2.0)
        plot.bgcolor = "white"
        container.add(plot)

        # Add the title at the top
        container.overlays.append(PlotLabel("Smith Chart",
                                  component=container,
                                  font = "swiss 16",
                                  overlay_position="top"))

        return Window(self, -1, component=container)


if __name__ == "__main__":
    demo_main(MyFrame, size=(600, 600), title="Simple Smith Chart")
#===============================================================================
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)

    def _plot_default(self):
        return _create_plot_component()


demo = Demo()


#===============================================================================
# Stand-alone frame to display the plot.
#===============================================================================
class PlotFrame(DemoFrame):
    def _create_window(self):

        # Return a window containing our plot
        return Window(self, -1, component=_create_plot_component())


if __name__ == "__main__":
    demo_main(PlotFrame, size=size, title=title)
Beispiel #7
0
                                        always_on=False))

        # Set the timer to generate events to us
        timerId = wx.NewId()
        self.timer = wx.Timer(self, timerId)
        self.Bind(wx.EVT_TIMER, self.onTimer, id=timerId)
        self.timer.Start(50.0, wx.TIMER_CONTINUOUS)
        return Window(self, -1, component=plot)

    def onTimer(self, event):
        # adjust the index and increment
        if self.current_index <= self.numpoints/8:
            self.increment = 2
        elif self.current_index == self.numpoints:
            self.increment = -2

        self.current_index += self.increment
        if self.current_index > self.numpoints:
            self.current_index = self.numpoints

        self.plot.index.set_data(self.x_values[:self.current_index])
        self.plot.value.set_data(self.y_values[:self.current_index])
        self.plot.request_redraw()
        return


if __name__ == "__main__":
    demo_main(PlotFrame, size=(600,500), title="Simple line plot")

# EOF
Beispiel #8
0
        self.event_state = "normal"
        event.window.set_pointer(self.normal_pointer)
        event.window.set_mouse_owner(None)
        event.handled = True
        self.request_redraw()
        return

    def moving_mouse_leave(self, event):
        self.moving_left_up(event)
        event.handled = True
        return

class MainFrame(DemoFrame):
    def _create_window(self):
        a = Box(bounds=[75, 75], position=[50,50], fill_color=(1, 0, 0, 1))
        b = Box(bounds=[75, 75], position=[200,50], fill_color=(0, 1, 0, 1))
        c = Box(bounds=[75, 75], position=[50,200], fill_color=(0, 0, 1, 1))
        cont = Container(a, b, c, bounds=[400,400], border_visible=True, bgcolor="lightgray")
        #cont.unified_draw = True
        #cont.draw_layer = "background"
        cont2 = Container(bounds=[300,300], border_visible=True, bgcolor="cyan")
        cont.tools.append(MoveTool(cont, drag_button="left"))
        cont2.tools.append(MoveTool(cont2, drag_button="left"))
        outer = Container(cont, cont2, fit_window=True)
        return Window(self, -1, component=outer)


if __name__ == "__main__":
    demo_main(MainFrame, size=(800,800), title="ClipTest")

Beispiel #9
0
# Chaco imports
from enthought.chaco.api import ArrayPlotData, HPlotContainer, Plot

class PlotFrame(DemoFrame):

    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)
        
if __name__ == "__main__":
    demo_main(PlotFrame, size=(900,500), title="Basic x-y plots")
Beispiel #10
0
                animated_plot = AnimatedPlot(common_index, jn(i,x), color)
                animated_plot.plot.index_mapper.range = index_range
                animated_plot.plot.value_mapper.range = value_range
            container.add(animated_plot.plot)
            self.animated_plots.append(animated_plot)


        for i, a_plot in enumerate(self.animated_plots):
            a_plot.plot.position = [50 + (i%3)*(PLOT_SIZE+50), 50 + (i//3)*(PLOT_SIZE+50)]


        # Set the timer to generate events to us
        timerId = wx.NewId()
        self.timer = wx.Timer(self, timerId)
        self.Bind(wx.EVT_TIMER, self.onTimer, id=timerId)
        self.timer.Start(100.0, wx.TIMER_CONTINUOUS)

        self.container = container
        return Window(self, -1, component=container)

    def onTimer(self, event):
        for plot in self.animated_plots:
            plot.timer_tick()
        return


if __name__ == "__main__":
    demo_main(PlotFrame, size=(1000,800), title="Updating line plot")

# EOF
Beispiel #11
0
    def _variable_changed(self, old, new):
        self.label.text = new.name
        self.value.text = str(new.binding)

    def _selected_changed(self, old, new):
        if self.selected:
            self.bgcolor = self.highlight_color
            self.icon.event_state = "selected"
        else:
            self.bgcolor = "clear"
            self.icon.event_state = "normal"


if __name__ == "__main__":
    from enthought.enable.api import Window
    from enthought.enable.api import Container
    from enthought.enable.example_support import DemoFrame, demo_main
    from enthought.block_canvas.function_tools.function_variables import InputVariable

    class MyFrame(DemoFrame):
        def _create_window(self):
            input = InputVariable(name="foo", default=3)

            box = IOField(input, position=[50, 300], bounds=[150, 15])

            container = Container(bounds=[800, 600])
            container.add(box)
            return Window(self, -1, size=[800, 600], component=container)

    demo_main(MyFrame)
# is also available online at http://www.simvisage.com/licenses/BSD.txt
#
# Thanks for using Simvisage open source!
#
# Created on Jun 10, 2009 by: rch

import enthought.traits.api 
from enthought.enable.api import Container, TextField, Window
from enthought.enable.example_support import DemoFrame, demo_main

class MyFrame(DemoFrame):
    def _create_window(self):
        text_field = TextField(position=[25,100], width=200)

        text = "This a test with a text field\nthat has more text than\n"
        text += "can fit in it."
        text_field2 = TextField(position=[25,200], width=200,
                                height=50, multiline=True, 
                                text=text, font="Courier New 14")

        text_field3 = TextField(position=[250,50], height=300, 
                                width=200, multiline=True,
                                font="Courier New 14")

        container = Container(bounds=[800, 600], bgcolor='grey')
        container.add(text_field, text_field2, text_field3)
        return Window(self, -1, component=container)

if __name__ == '__main__':
    demo_main(MyFrame, size=(800, 600))
Beispiel #13
0
        vertical_line = LinePlot(
            index=ArrayDataSource(array([2.5, 2.5], dtype=float)),
            value=ArrayDataSource(array([-0.4, 0.4], dtype=float)),
            color="green",
            index_mapper=LinearMapper(range=view.index_range),
            value_mapper=LinearMapper(range=view.value_range),
        )

        # Add the plot's index and value datasources to the dataview's
        # ranges so that it can auto-scale and fit appropriately
        view.index_range.sources.append(vertical_line.index)
        view.value_range.sources.append(vertical_line.value)
        view.index_range.sources.append(lineRed.index)
        view.value_range.sources.append(lineRed.value)
        view.value_range.sources.append(lineBlue.value)

        # Add the renderers to the dataview.  The z-order is determined
        # by the order in which renderers are added.
        view.add(lineRed)
        view.add(lineBlue)
        view.add(vertical_line)

        view.tools.append(PanTool(view))
        view.overlays.append(ZoomTool(view))

        return Window(self, -1, component=view)


if __name__ == "__main__":
    demo_main(PlotFrame, size=(800, 700), title="two graphs example")
Beispiel #14
0
        plot.overlays.append(text)

        # Add some static labels. 
        label2 = DataLabel(component=plot, data_point=(x[20], y[20]),
                           label_position="bottom right",
                           border_visible=False,
                           bgcolor="transparent",
                           marker_color="blue",
                           marker_line_color="transparent",
                           marker = "diamond",
                           arrow_visible=False)
        plot.overlays.append(label2)

        label3 = DataLabel(component=plot, data_point=(x[80], y[80]),
                           label_position="top", padding_bottom=20,
                           marker_color="transparent",
                           marker_size=8,
                           marker="circle",
                           arrow_visible=False)
        plot.overlays.append(label3)
        
    
        container.add(plot)

        return Window(self, -1, component=container)

if __name__ == "__main__":
    demo_main(PlotFrame, size=(800,700), title="Data label example")

# EOF
Beispiel #15
0
    def _create_window_mt(self):
        viewport = self._create_viewport()

        from enactable.configuration import arg_parser, get_global_config
        from enactable.enable.enable_blob_listener import BlobWindow
        from enactable.enable.blobprovider import NetworkBlobProvider
        parser = arg_parser()
        args = parser.parse_args()
        cfg = get_global_config()
        tconf = cfg.tconf
        tconf.from_arguments(args)

        provider = NetworkBlobProvider(host=tconf.Server.host, port=tconf.Server.port)
        provider.start()
        return BlobWindow(self, -1, component=viewport, blob_provider=provider)

    def _create_window_simple(self):
        viewport = self._create_viewport()
        return Window(self, -1, component=viewport)

    def _create_window(self):
        if MULTITOUCH:
            return self._create_window_mt()
        else:
            return self._create_window_simple()

if __name__ == "__main__":
    demo_main(PlotFrame, size=(1000,700), title="PlotCanvas")

# EOF
# Chaco imports
from enthought.chaco.api import create_polar_plot, create_line_plot

class MyFrame(DemoFrame):
    def _create_window(self):
        # Create theta data
        numpoints = 5000
        low = 0
        high = 2*pi
        theta = arange(low, high, (high-low) / numpoints)

        # Create the radius data
        radius = cos(3*theta)

        # Create a new polar plot with radius and theta data
        plot = create_polar_plot((radius,theta),color=(0.0,0.0,1.0,1), width=4.0)

        label = DataLabel(component=plot, data_point=(radius[100],theta[200]),
                          padding=40,
                          label_format = 'What shall I write here?',
                          bgcolor = "transparent",
                          border_visible=False)
        plot.overlays.append(label)        

        return Window(self, -1, component=plot)

if __name__ == "__main__":
    demo_main(MyFrame, size=(600,600), title="Simple Polar Plot")

# EOF#######################
Beispiel #17
0
                  'Opening backup data.'
            run_cleanup = False
            raise

        tar_file = tarfile.open(tar_path)
        try:
            os.mkdir(voldata_path)
        except:
            pass
        tar_file.extractall(voldata_path)
        tar_file.close()
        os.unlink(tar_path)
    else:
        print 'Previously downloaded data detected.'

def cleanup_data():
    global dl_path

    answer = raw_input('Remove downloaded files? [Y/N]: ')
    if answer.lower() == 'y':
        try:
            shutil.rmtree(os.path.join(dl_path, 'voldata'))
        except:
            pass

if __name__ == "__main__":
    demo_main(PlotFrame, size=(800,700), title="Cube analyzer")
    if run_cleanup:
        cleanup_data()