From: Néstor Espinoza <nestor.espinozap@gm...>  20130415 19:03:21

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 