[R] Plot frame border to start at zero?

Douglas M. Hultstrand dmhultst at metstat.com
Wed Jan 20 01:42:27 CET 2010


Hello,

I am creating plots of hourly precipitation and accumulated 
precipitation (on different axis, see attached image). I was wondering 
how can I have the plot frame (black border) start at zero, it looks 
like it is plotted less than zero? 

The code I use to create the png files is below:

CairoPNG(PNG_file,width=1000, height=600, pointsize=14, bg="white")
        opar <- par(mai = c(.8, .8, 1, .8))    # Set margins
        plot(ppt,type="h",col="dark grey",ylim=c(0,max_ppt+1), lwd=6, 
xlab='', ylab='', main=title, frame.plot=T, axes=F)
        axis(2, col="black", las=2)
        par(new=T) # R to overwrite the first plot
        plot(accum, type="l", col="blue", axes=F, ylab='', xlab='', lwd=2)
        axis(1, col="black", las=1)
        axis(4, pretty(c(0, max_accum) ), col="black", las=2)
        legend("topleft", legend=c('Incremental', 'Accumulated'),  
col=c("dark grey", "blue"), lwd=c(6, 2.0))
        legend((length(n)-4),max_accum, 
legend=paste(round(max_accum,2)), bty="n", cex=.90)     ### max accum 
location
        mtext(paste("Lat:", .lat, "Lon:", .lon), cex=0.95)
        mtext("Index Hour", side=1, line=2)
        mtext("Incremental Precipitation (in)", side=2, line=2.5)
        mtext("Accumulated Precipitation (in)", side=4, line=2)
dev.off()


Thanks for all your help,
Doug

---------------------------------
Douglas M. Hultstrand, MS
Senior Hydrometeorologist
Metstat, Inc. Windsor, Colorado
voice: 970.686.1253
email: dmhultst at metstat.com
web: http://www.metstat.com
---------------------------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mass_curve_33.355-111.325_1147_Zone1.png
Type: image/png
Size: 36251 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100119/83b82452/attachment.png>


More information about the R-help mailing list