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