Dynamic view

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic view

Robert Unguran
Hi,

I am trying to use the Raspberry Pi as a logic analyser, because of this I am trying to create a view in python by using chaco.

I have the following questions:

  1. How can I disable the zoom and pan in the y axis?
  2. How can I add labels dynamically in front of each plots?
  3. In this case when the value is 1 or 0 it is hard to see the line, how can I fix that?
 

This is my early try:

    application = GUIAPI       

    visu = Instance( BasicVisualisationVariables )    

    chanel_nr = DelegatesTo( 'visu' )

    visu_data = DelegatesTo( 'visu' )

    

    container = Instance( VPlotContainer )

    label_container = Instance( HGroup ) 

    chanels = {}    

    traits_view = View( 

                       VGroup( 

                              UItem( 'container', editor = ComponentEditor( size = ( 800, 600 ) ) ),

                              )

                       )        

    def __init__( self, *args, **kwargs ):

        super( BasicVisualisationView, self ).__init__( *args, **kwargs )

        self.draw_data()

        

    def draw_data( self ):

        """

        """
        self.container = VPlotContainer( padding = 10, fill_padding = True,

                                        bgcolor = "gray", use_backbuffer = False )

        self.label_container = HGroup()

        for i in range( 0, self.chanel_nr ):

            los1 = ArrayPlotData()

            los1.set_data( "xdata", [1, 2, 2, 3, 3, 4] )

            los1.set_data( "ydata", [1, 1, 0, 0, 1, 1] )            

            plot = Plot( los1 )

            plot.plot( ( "xdata", "ydata" ), color = "blue" )            

            plot.padding = 5

            zoom = ZoomTool( component = plot, tool_mode = "box", always_on = False )

            plot.overlays.append( zoom )            

            pan = PanTool( component = plot, tool_mode = "box", always_on = False )

            plot.tools.append( pan )            

            self.container.add( plot )

            self.chanels[i] = plot

            self.label_container.content.append( Item( "Text" ) )

            if i > 0:

                self.chanels[i].index_range = self.chanels[i - 1].index_range
A simple version are here: https://github.com/runguran/pyla

Thank you very much for your help,

Regards,
Robert


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic view

John Wiggins
Howdy Robert,

1. You can constrain zooming using the `axis` trait in ZoomTool. The accepted values are 'both', 'index', and 'value'. Similarly, you can constrain PanTool with its `constrain_direction` trait, whose accepted values are None, 'x', or 'y'. (and now that I've written that, I cringe at the inconsistency…)

2. I'm not sure what you mean by "in front of each plot[s]".

3. You can add a margin to a plot by using the `tight_bounds` trait on DataRange1D/DataRange2D. In your case, I think that will be `plot.value_range.tight_bounds`. You might have to dig around a little. There is also a `margin` trait in the DataRange*D classes which controls the size of the margin when `tight_bounds` is True.

Hope that helps!

-- John

On Dec 13, 2013, at 10:35 AM, Robert Unguran <[hidden email]> wrote:

> Hi,
>
> I am trying to use the Raspberry Pi as a logic analyser, because of this I am trying to create a view in python by using chaco.
>
> I have the following questions:
>
> • How can I disable the zoom and pan in the y axis?
> • How can I add labels dynamically in front of each plots?
> • <gecbgfaf.png> In this case when the value is 1 or 0 it is hard to see the line, how can I fix that?
>  
> [… snip ...]
> Thank you very much for your help,
>
> Regards,
> Robert
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev