[R-sig-Geo] Dont show zero values in line graph

Edzer Pebesma edzer.pebesma at uni-muenster.de
Fri Jan 7 08:43:14 CET 2011



On 01/07/2011 04:11 AM, jroll wrote:
> 
> Hey everyone,
>    Im getting better at plotting my data but cant for the life of me figure
> out how to show a line graph with missing data that doesnt continue the line
> down to zero then back up to the remaining values.
> 
> Consider the following
> x<-c(1:5,0,0,8:10)
> y<-1:10
> 
> plot(0,0,xlim=c(0,10), ylim=c(0,10),type="n",main="Dont show the bloody 0
> values!!")
> lines(x~y, col="blue", lwd=2,)
> 
> My data is missing the 6th and 7th values and they come in as NA's so i
> change them to 0s but then the plot has these ugly lines that dive toward
> the x axis then back up.  I would do bar plots but i need to show multiple
> sets of data on the same and side by side bars doesnt do it for me.  
> 
> So i need a line graph that starts and stops where 0s or missing values
> exist.  Thoughts?

x<-c(1:5,NA,NA,8:10)
y<-1:10

plot(0,0,xlim=c(0,10), ylim=c(0,10),type="n",main="Dont show the bloody 0
values!!")
lines(x~y, col="blue", lwd=2,)

> 
> JR 

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list