hi, i'm using traits and chaco to interactively analyze neuroscience data for my phd. i love it! now i bumped into an issue i dunno how to deal with it: for better understanding see code attached. i defined a TimeseriesPlot instance consisting of a ArrayPlotData and a Plotcontainer instance and some functions to easily add different plots to a container. for example i can do the following: --------------------------- In [125]: data = [] In [126]: data.append(numpy.random.rand(100)) In [127]: data.append(numpy.random.rand(100)) In [128]: data.append(numpy.random.rand(100)) In [129]: tsp = sc.TimeseriesPlot() In [132]: tsp.add_single_trace_plot(data[0], 10., 'test') In [134]: tsp.add_temp_distribution_plot(numpy.array(data), 10, 'testdistr') In [135]: tsp.configure_traits() --------------------------- this nicely plots data into the plotcontainer. but two things i do not understand: -> if i create a second TimeseriesPlot instance, lets say In [136]: tsa = sc.TimeseriesPlot() In [137]: tsa.configure_traits() the new plotcontainer already contains the previous plots?! why is that? i would like to loop over loads of traces from different origins and save the plots as pdfs and pngs. but this really messes it up! how do i get empty an empty plotcontainer and plotdata instance every time i create a TimeseriesPlot instance? -> on my macbook when calling configure_traits() i first have to resize my window to see a plot, before that i only have an gray, empty window. why? what to do? (this is not the case on my ubuntu workstation) thanks a lot for hints! michael _______________________________________________ Enthought-Dev mailing list [hidden email] https://mail.enthought.com/mailman/listinfo/enthought-dev |
On Sun, Nov 14, 2010 at 5:04 PM, Michael Graber
<[hidden email]> wrote: > the new plotcontainer already contains the previous plots?! why is that? > i would like to loop over loads of traces from different origins and save > the plots as pdfs and pngs. but this really messes it up! > how do i get empty an empty plotcontainer and plotdata instance every time i > create a TimeseriesPlot instance? Your problem is that your plotdata and plotcontainer attributes are *class* attributes, and not *traits*. This means that all instances of the class share those attributes. What you really want to do is use an Instance trait, thusly: class TimeseriesPlot(HasTraits): plotdata = Instance(ArrayPlotData, ()) plotcontainer = Instance(VPlotContainer, kw=dict(resizable="hv", bgcolor="white", fill_padding=True, padding=PLOTPADDING)) > -> on my macbook when calling configure_traits() i first have to resize my > window to see a plot, before that i only have an gray, empty window. why? > what to do? > (this is not the case on my ubuntu workstation) I am not sure why this is happening to you... it doesn't happen to the chaco demos that use the ComponentEditor and .configure_traits()... Perhaps try fixing the class attribute/instance trait issue above, and see if that helps matters? -Peter _______________________________________________ Enthought-Dev mailing list [hidden email] https://mail.enthought.com/mailman/listinfo/enthought-dev |
>> the new plotcontainer already contains the previous plots?! why is >> that? >> i would like to loop over loads of traces from different origins >> and save >> the plots as pdfs and pngs. but this really messes it up! >> how do i get empty an empty plotcontainer and plotdata instance >> every time i >> create a TimeseriesPlot instance? > > Your problem is that your plotdata and plotcontainer attributes are > *class* attributes, and not *traits*. This means that all instances > of the class share those attributes. What you really want to do is > use an Instance trait, thusly: > > class TimeseriesPlot(HasTraits): > plotdata = Instance(ArrayPlotData, ()) > plotcontainer = Instance(VPlotContainer, kw=dict(resizable="hv", > bgcolor="white", fill_padding=True, padding=PLOTPADDING)) but i must admit that do not fully understand the distinction between class attributes and traits and also the traits type Any. is there some documentation about that somewhere? > >> -> on my macbook when calling configure_traits() i first have to >> resize my >> window to see a plot, before that i only have an gray, empty >> window. why? >> what to do? >> (this is not the case on my ubuntu workstation) > > I am not sure why this is happening to you... it doesn't happen to the > chaco demos that use the ComponentEditor and .configure_traits()... > Perhaps try fixing the class attribute/instance trait issue above, and > see if that helps matters? i could not find an example that uses the ComponentEditor and .configure_traits() directly. all the examples i checked use an enable.api Window somehow to display plots. this works. but these examples have the same problem if you use the .configure_traits() method on the plot class. for example bar_plot.py https://svn.enthought.com/enthought/browser/Chaco/trunk/examples/bar_plot.py : from bar_plot import Demo demo = Demo() demo.configure_traits() the enable Window seems to go very deep down into wx handling .. -------- now that the TimeseriesPlot works i want to loop over many traces, generate a plot and save it as a pdf or a bmp. but if i do not use the configure_traits() method on the timeseries object the saved pdf is empty. however, i do really not want to have hundreds of windows being opened! is there a way to 'render the plot' without calling configure_traits() now, in the case of my MacBook i have to use .configure_traits() and then resize the window, otherwise the pdf is empty. this can't be the way ;) btw. regarding the other pdf mailing list thread: saving pdf of a VPlotContainer like in my code works perfectly, apart from different line_styles .. thanks for your help, michael _______________________________________________ Enthought-Dev mailing list [hidden email] https://mail.enthought.com/mailman/listinfo/enthought-dev |
Free forum by Nabble | Edit this page |