Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Néstor Espinoza <nestor.espinozap@gm...>  20130415 19:03:21
Attachments:
Message as HTML

Hello everyone, I have a 'small' question regarding the combination of legends. Suppose I have a model, and the binned version of it in two vectors, say, model, with the corresponding values for x, x_model and binned_model with the corresponding values of x, x_binned_model. What I want to do is to plot this using pyx, but, in the legend, combine the symbol I use for the binned version of the model with the model itself, which I plot as a line. So I have something like the following code: ######################################### from pyx import * from numpy import np # Create a model x = np.array([0,1,2,3,4,5,6]) model = x**2 # Bin two values; 0.5, binned between 0 and 1, and 4.5, binned between 4 and 5: x_binned_model = np.array([0.5,4.5]) x_binned_model = np.array([0.33,20.33]) c = canvas.canvas() g = c.insert(graph.graphxy(height=5,width=10, key=graph.key.key(pos='bl'),\ x = graph.axis.linear(title = 'x axis'),\ y = graph.axis.linear(title = 'y axis'))) # Plot 'full version' of the model: g.plot(graph.data.values(x=x_model,y=model, title = 'The model',\ styles = [graph.style.line([color.cmyk.CornflowerBlue,\ style.linestyle.solid,\ style.linewidth.THIN])]) # ...binned version of the model: g.plot(graph.data.values(x=x_binned_model, y=binned_model, title = 'The model'),\ styles = [graph.style.symbol(graph.style.symbol.square,symbolattrs = [deco.filled([color.cmyk.CornflowerBlue]), deco.stroked([color.cmyk.CornflowerBlue])],size = 0.1)]) c.writePDFfile("Figure") ######################################### So when you plot it, you have two legends: one with a line for the model and one with squares for the bined model: is there a way to combine the two and just have one legend, with the line and the square overplotted on it? Cheers  Néstor 
From: Joerg Lehmann <joergl@us...>  20130416 07:51:58

Hello Nor, I think precisely this use case has been documented in http://pyx.sourceforge.net/examples/graphs/join.html HTH, J On 15.04.13, Néstor Espinoza wrote: > Hello everyone, > > I have a 'small' question regarding the combination of legends. Suppose I > have a model, and the binned version of it in two vectors, say, model, > with the corresponding values for x, x_model and binned_model with the > corresponding values of x, x_binned_model. > What I want to do is to plot this using pyx, but, in the legend, combine > the symbol I use for the binned version of the model with the model > itself, which I plot as a line. So I have something like the following > code: > > ######################################### > from pyx import * > from numpy import np > # Create a model > x = np.array([0,1,2,3,4,5,6]) > model = x**2 > # Bin two values; 0.5, binned between 0 and 1, and 4.5, binned between 4 > and 5: > x_binned_model = np.array([0.5,4.5]) > x_binned_model = np.array([0.33,20.33]) > c = canvas.canvas() > g = c.insert(graph.graphxy(height=5,width=10, > key=graph.key.key(pos='bl'),\ > x = graph.axis.linear(title = 'x axis'),\ > y = graph.axis.linear(title = 'y axis'))) > # Plot 'full version' of the model: > g.plot(graph.data.values(x=x_model,y=model, title = 'The model',\ > styles = [graph.style.line([color.cmyk.CornflowerBlue,\ > style.linestyle.solid,\ > style.linewidth.THIN])]) > # ...binned version of the model: > g.plot(graph.data.values(x=x_binned_model, y=binned_model, title = 'The > model'),\ > styles = > [graph.style.symbol(graph.style.symbol.square,symbolattrs = > [deco.filled([color.cmyk.CornflowerBlue]), > deco.stroked([color.cmyk.CornflowerBlue])],size = 0.1)]) > c.writePDFfile("Figure") > ######################################### > > So when you plot it, you have two legends: one with a line for the model > and one with squares for the bined model: is there a way to combine the > two and just have one legend, with the line and the square overplotted on > it? > Cheers >  > Nor >  > Precog is a nextgeneration analytics platform capable of advanced > analytics on semistructured data. The platform includes APIs for building > apps and a phenomenal toolset for data science. Developers can use > our toolset for easy data analysis & visualization. Get a free account! > http://www2.precog.com/precogplatform/slashdotnewsletter > _______________________________________________ > PyXuser mailing list > PyXuser@... > https://lists.sourceforge.net/lists/listinfo/pyxuser 
Sign up for the SourceForge newsletter:
No, thanks