How to create a stair step plot of data in R/ggplot2?

Sunday, May 4, 2014

I have a list of points and I'd like to plot them and connect them with stair steps, like the following screenshot.



df <- read.table('out.dat')
df <- df[df$V1>0,]
st <- stats.bin(x=df$V1, y=df$V2, N=100)
df2 <- as.data.frame(st$stats["mean",])
names(df2) <- c('mean.energy')
plot(df2$mean.energy, type="s",
xlab="Off-axis distance (mm)", ylab="Mean Energy (MeV)")


How could I achieve the same with ggplot2 ?


enter image description here







http://ift.tt/1mtb0j1