From: Andre W. <wo...@us...> - 2005-07-06 13:07:41
|
Hi John, On 01.07.05, John Owens wrote: > I have several instances of a class Dataset, and Dataset has a "plot" > routine that calls graph.plot(). > > What I would like is a plot routine that uses a different symbol each > time it's called. It needs to do this automatically - say, an internal > counter that increments itself each time it's called. Seems like this > would be a useful function to provide internally within PyX. > > Pseudocode: > > class Dataset: > data = [] > def plot(): > plot(data, symbol()) > > Dataset a, b, c > a.plot() # should use cross > b.plot() # should use plus > c.plot() # should use square > > This could perhaps be done as: > > a.plot(next_symbol()) # next_symbol() returns cross > b.plot(next_symbol()) # next_symbol() returns plus > c.plot(next_symbol()) # next_symbol() returns square > > It would seem beneficial to put this in the faq, and to have an > example in the examples that uses two different datasets (with > different symbols) on the same graph. > > Thanks! Enjoying using this package very much. I may not fully understand your problem. The styles (including the symbols used in the symbol style graph.style.symbol) are allowed to be changeable. Suppose you have several (two in this example) data instances d1 and d2. Than the following plot command will alter the symbols used for d1 and d2: g.plot([d1, d2], [graph.style.symbol()]) Alternatively you can also issue two plot commands when using the same styles instances: styles = [graph.style.symbol()] g.plot(d1, styles) g.plot(d2, styles) ... will also alter the symbol. However, the last version will not, since it uses *different* styles: g.plot(d1, [graph.style.symbol()]) g.plot(d2, [graph.style.symbol()]) I'm not yet sure whether this answer is releated to your question. André -- by _ _ _ Dr. André Wobst / \ \ / ) wo...@us..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript figures with Python & TeX (_/ \_)_/\_/ visit http://pyx.sourceforge.net/ |