是否有任何r代码提供折减折线图的输出?

时间:2019-10-19 12:19:22

标签: r graph representation

我想用r代码表示类似于此图像的离散折线图,请帮助我。假定任何值。

enter image description here

我尝试过的事情和数据集在这里

bus.stop<-c("Polic Chowk","Regional bus stand","hospital", "Alanpura", "Housing Colony", "PG College", "Ranthambore circle" , "Railway station", "Collectorate", "New Bus stand")

boarding<-c(18,9,15,3,7,1,1,0,0,0)
alighting<-c(0,3,7,5,8,1,13,8,5,4)
load<-c(18,24,38,32,29,27,23,11,4,0)

hous.oton<-data.frame("BusStop" = bus.stop, "Boarding" = boarding, "Alighting"=alighting, "Load"=load)

plot(hous.oton$BusStop,hous.oton$Boarding, type="s")
```

1 个答案:

答案 0 :(得分:0)

如果您只想绘制阶梯状的线图,则可以使用ggplot2软件包来获取它:

library(ggplot2)
ggplot(hous.oton, aes(x=BusStop, y=Boarding, group=1)) + geom_step()

您需要指定group = 1,因为每个公交车站只有一个观测站。

有关更多信息,请参见例如Creating a cumulative step graph in R