[R] Graph is without line
Jim Lemon
jim at bitwrit.com.au
Wed Sep 25 02:24:24 CEST 2013
On 09/24/2013 10:46 PM, mohan.radhakrishnan at polarisft.com wrote:
> Hi,
> Sometimes I get a graph like the attached one. The data type could
> have something to do with it. This graph does not use the color and does
> not draw
> a line. Earlier I used to convert the factors in the data frame to another
> data type and drew the correct graphs.
>
> Any idea why this happens ?
>
> Thanks,
> Mohan
>
> Var1 Freq
> 1 10.1.17.10 205
> 2 10.1.17.15 216
> 3 10.1.17.17 79
> 4 10.1.17.23 76
> 5 10.1.17.24 209
> 6 10.1.17.5 244
> 7 10.1.17.6 178
> 8 10.1.17.7 165
> 9 10.1.17.8 146
>
>
>
> #prints factor
> print(class(data$Var1))
>
> plot(data$Var1,data$Freq,ylim=c(0,700),col="green",type="o",ylab="",xlab="",las=2,lwd=2.5,xaxt="n")
> title("Estimation of concurrent connections",cex.main=3)
> library(plotrix)
> staxlab(at=data$Var1,
> labels=as.character(data$Var1),nlines=3,srt=90)
>
Hi Mohan,
If you pass a factor as the "x" value to plot, it assumes that the
values of the factor are nominal or at best ordinal and does not try to
connect them into a metric scale. You can get a "line" with:
plot(as.numeric(data$Var1),data$Freq,ylim=c(0,700),col="green",type="o",
ylab="",xlab="",las=2,lwd=2.5,xaxt="n")
...
but think carefully about whether this means anything sensible.
Jim
More information about the R-help
mailing list