質問

How can I use ggplot2's geom_line to plot a square function, where x,y coordinates are connected by squares rather than by lines?

Something that looks like:

enter image description here

Is this possible?

役に立ちましたか?

解決

For this you can use geom_step:

df = data.frame(x = 1:10, 
                y = sample(c(1,2), 10, replace = TRUE))
ggplot(df, aes(x = x, y = y)) + geom_step()

enter image description here

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top