R - ggplot - geom_bar的圆形极限

时间:2015-04-24 11:15:57

标签: r ggplot2 geom-bar

这是我的条形图的简单示例:

x <- data.frame(aa=c(0.2,0.6,0.1), dd = c(1,2,3))
x <- melt(x, "dd")
y <- data.frame(bb=c(0.4,0.5), dd = c(1,2))
y <- melt(y, "dd")
z <- data.frame(cc=c(0.5,0.25,0.1,0.05), dd = c(1,2,3,4))
z <- melt(z, "dd")

x=rbind(x,y,z)

col=c("white","grey","blue","white","red","white","green","blue","green")
ggplot(x, aes(x = variable, y = value)) + geom_bar(stat = "identity", fill = col)

我想知道是否有一种方法可以为我的条形图设置圆形末端,例如行(http://sape.inf.usi.ch/quick-reference/ggplot2/lineend)的lineend选项?

1 个答案:

答案 0 :(得分:0)

这是一个示例,其中条形末端为圆形,与 geom_line (geom_path) 一起使用,用作最小示例。

df1 <- data.frame( x=c(1,1,2,2,3,3),
                   y=c(1,7,1,4,1,5),
                   chr=c("one","one","two","two","three","three") )

ggplot( df1, aes(x,y, col=chr) ) + geom_line( lineend="round", lwd=10 )

ggplot_geom_line