r - Save an plot to an image, then draw additional lines on plot and save again. -


i'm trying draw stripchart in r, save png file, draw more stuff on , save again. attempts far ended in error plot.new has not been called yet. corresponding code is

  # draw without lines   png(c(name, '.png'), width=480, height=240);   stripchart(data, pch=4, method='jitter');   dev.off();    # draw with lines   png(c(name, '_with_trim_points', '.png'), width=480, height=240);   abline(v=points, untf = false, col='red');   abline(v=more__points, untf = false, col='green')   dev.off(); 

just calling stripchart(data, pch=4, method='jitter'); second time not option, since jitter different , end different scatterplot.

with seed , generated data

#generate data data=data.frame(x=rnorm(40),y=rnorm(40)) points=c(-2,0) more__points=c(1,2)    # draw without lines set.seed(123) png(paste0(name, '.png'), width=480, height=240); stripchart(data, pch=4, method='jitter'); dev.off();  # draw with lines set.seed(123) png(paste0(name, '_with_trim_points', '.png'), width=480, height=240); stripchart(data, pch=4, method='jitter'); abline(v=points, untf = false, col='red'); abline(v=more__points, untf = false, col='green') dev.off(); 

enter image description here enter image description here


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -