I have the following simple code that attempts to show three graphs in the same plot. The two last graphs I ask for with the “lines”-function won’t show and I am at my wits end. Is this a bug or am I doing something stupid?
Workarounds, or ways of doing this not using “lines” also appreciated.
No error messages, but won’t show the lines I ask for (see the r.lines() calls below).
from rpy2.robjects import r
from rpy2.robjects.packages import importr
grdevices = importr('grDevices')
d = {0: {0: 5669, 800: 1001, 100: 2240, 200: 1606, 300: 1366, 400: 1236, 500: 1146, 600: 1083, 900: 964, 700: 1037}, 10: {0: 0, 800: 155, 100: 229, 200: 218, 300: 194, 400: 178, 500: 171, 600: 165, 900: 150, 700: 160}, 5: {0: 0, 800: 195, 100: 415, 200: 330, 300: 279, 400: 258, 500: 241, 600: 219, 900: 185, 700: 201}}
x = range(0,1000,100)
y = [d[0][i] for i in x]
z = [d[5][i] for i in x]
ae = [d[10][i] for i in x]
#grdevices.pdf(file = 'reads_per_slackvalue_and_cluster_size.pdf')
r.plot(x,y, main='Reads per slack value', xlab='slack value',ylab='number of reads', type='l', col='blue')
r.lines(x, z, col='red')
r.lines(x, ae, col='green')
#r.legend("topleft", ['0','5','10'], ['blue','red','green'])
#grdevices.dev_off()
show_image = raw_input()
This is the result:

This is what I get doing the same stuff interactively in R (more correct):

Are you sure about your rpy2 code ? Two hints:
The rpy2-produced plot and the R-plot show rather different curve shapes. May be something to investigate ?
The two lines below added to your code do make a second line. Definitely worth checking that your x and y coordinates are within the plotting area.
code: