Tuesday 15 September 2015

ggplot2 - R ggsave save thumbnail size (200 x 200),scaled image -



ggplot2 - R ggsave save thumbnail size (200 x 200),scaled image -

i trying plot simple x,y line plots info in loop. code generate hundreds of such plots , thought save these plots in thumbnail size image (something 200 x 200 pixels, dpi wont matter) , embed in excel file along data. when plot through ggplot2 looks fine when want save it, either cropped image showing part of image or narrow plot mismatched sizes of labels/texts. if set scale 2 looks right not fit criteria.

my info frame looks this.

drug=c("a","a","a","a","a","a") con=c(10,100,1000,10,100,1000) treatment=c("dox","dox","dox","pac","pac","pac") value=c(-3.8,-4.5,-14.1,4,-4.6,3.5) mat_tbl=data.frame(drug,con,treatment,value) p=ggplot(data=mat_tbl,aes(x=con,y=value,colour=treatment,group=treatment))+geom_point(size = 4)+geom_line()+labs(title="drug a",x="concentration",y="value") + scale_y_continuous(limits=c(-25,125),breaks=seq(-25,125,by=25)) + theme_bw() ggsave(filename = "curve_drug.png",plot=p,width=2,height=2,units="in",scale=1)

any suggestions parameters need work on?

r ggplot2

No comments:

Post a Comment