This may sound really simple but I\'m trying to find the equivalent code to plot(x,y, type=\"h\")
as a qplot code. I already have:
qplot(x,y,
It's a little clunky, but I think you need geom_segment()
.
d <- data.frame(x=1:5,y=c(0.1,0.4,0.8,0.2,0.9))
library(ggplot2)
qplot(x=x,xend=x,y=0,yend=y,data=d,geom="segment")
## or equivalently
ggplot(d,aes(x=x,xend=x,y=0,yend=y))+geom_segment()
This gives (y label adapted):
In contrast, using the histogram with stat=identity
:
qplot(data = d, x=x, y=y, stat="identity")
gives:
For completeness, the plot
with type='h'
looks like this: