针图在ggplot2 [英] needle plot in ggplot2

查看:183
本文介绍了针图在ggplot2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有一个像

  plot(1:10,1:10,type = h)

但是在 ggplot2 中。有没有或多或少直接的方式来做到这一点?或者只有通过折线图或类似的方法才可能实现?



解决方案

  library(ggplot2)
ggplot(data.frame(x = 1:10,y = 1:10),
aes(x = x,ymax = y,ymin = 0))+
geom_linerange()


I would like to have a needle plot like in

plot(1:10,1:10,type="h")

but in ggplot2. Is there a more or less direct way to do it? Or is that only possible with workarounds via line charts or something like that?

解决方案

library(ggplot2)
ggplot(data.frame(x=1:10, y=1:10),
       aes(x=x, ymax=y, ymin=0)) +
  geom_linerange()

这篇关于针图在ggplot2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆