Hi Brendon,

I don't know enough about the internals of PyXPlot to comment on how  
to best inject some additional features there. But I'm confident it's  
manageable.

Anyway, it's an interesting question for PyX itself. Maybe its trivial  
to transfer this to PyXPlot -- I don't know.

A quick and dirty solution could be to use the multi-column feature of  
the graph keys:

from pyx import *

titles = ["spam", "eggs"]
g = graph.graphxy(width=8, key=graph.key.key(columns=2, columndist=0))
g.plot(graph.data.file("minimal.dat", x=1, y=2, title=r"\vphantom{%s}"  
% titles[0]))
g.plot(graph.data.file("minimal.dat", x=1, y=2, title=r"\vphantom{%s}"  
% titles[1]))
g.plot(graph.data.function("y(x)=4*x", title=titles[0]))
g.plot(graph.data.function("y(x)=4*x", title=titles[1]))
g.writePDFfile("minimal")

However it's a more difficult to do it properly. The problem is that  
the graph key gets called with a list of plotitems drawn in the graph.  
I would not suggest to alter this. Instead my advice is to create an  
individual version of the graph.key.key-class.

To get started you should create a link between the corresponding  
plotitems. For example:

theory = g.plot(graph.data.file("minimal.dat", x=1, y=2))
experiment = g.plot(graph.data.function("y(x)=4*x", title="spam"))
experiment.corresponding_theory = theory

In the end you may nicely hide this in an individual plot command (by  
subclassing graph):

g.combiplot(graph.data.file("minimal.dat", x=1, y=2),  
graph.data.function("y(x)=4*x"), title="spam")

Once a link between the corresponding plotitems is injected in the  
plotitems, you just need to properly handle this in the graph key.  
Using the injection inserted above, you should evaluate  
hasattr(plotitem, "corresponding_theory") and do whatever you want  
along the lines of the original graph.key.key. In the end you just  
need to call the plotitems key_pt methods with proper arguments ...  
they take care with the style lists and internal data for the  
changeable attributes and all those bulky details ...

Best


André


Am 06.08.2009 um 10:08 schrieb Brendon Higgins:

> Hi list,
>
> I have a use case that I'm trying to solve: I have several pairs of  
> X/Y plots.
> Each pair consists of one line of numerical simulation data and one  
> set of
> experimentally measured points with error bars. The easy and simple  
> thing to
> do is to have each plot have a unique key entry (titles like "Some  
> plot title
> (numeric)", "Some plot title (experiment)"). But in context it  
> should be quite
> obvious that the lines are simulations and the dots are experimental  
> results,
> so it's really just a lot of annoying redundancy and wasted space.
>
> So I'm trying to come up with a way to combine the theory and  
> experiment lines
> into a single key entry. In particular, I want each title next to  
> all of the
> points and line indicators for the corresponding plots. Like this:
> X --- Some plot title
> O ... Another plot title
>
> I can't see a way to do this in PyX. So my half-baked idea is to  
> make a class
> that acts as a container for multiple plotitems, and has the same  
> interface as
> plotitem (maybe a subclass). Is this crazy? Anyone have a simpler  
> idea?
>
> I will confess that up to this point I've been using PyxPlot, rather  
> than PyX
> proper, but I don't think the conversion itself would be difficult.  
> I'd rather
> just get an opinion as to whether doing what I suggest really is  
> possible, or
> if there's an easier way that I've missed.
>
> Peace,
> Brendon
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008  
> 30-Day
> trial. Simplify your report design, integration and deployment - and  
> focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> PyX-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pyx-user
>

-- 
by  _ _      _    Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim
    / \ \    / )   [email protected], http://www.wobsta.de/
   / _ \ \/\/ /    PyX - High quality PostScript and PDF figures
  (_/ \_)_/\_/     with Python & TeX: visit http://pyx.sourceforge.net/


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user

Reply via email to