R-ggplot-geom_bar的四舍五入 [英] R - ggplot - Rounded extremity for geom_bar
本文介绍了R-ggplot-geom_bar的四舍五入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的barplot外观的简单示例:
x<-data.frame(aa = c(0.2,0.6,0.1),dd = c(1,2,3))x<-融化(x,"dd")y<-data.frame(bb = c(0.4,0.5),dd = c(1,2))y<-融化(y,"dd")z<-data.frame(cc = c(0.5,0.25,0.1,0.05),dd = c(1,2,3,4))z<-融化(z,"dd")x = rbind(x,y,z)col = c(白色",灰色",蓝色",白色",红色",白色",绿色",蓝色",绿色")ggplot(x,aes(x =变量,y =值))+ geom_bar(stat ="identity",fill = col)
我想知道是否有一种方法可以使我的钢筋具有圆角末端,例如线条的lineend选项(
This is a simple example of what my barplot look like :
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)
I'm wondering if there is a way to have rounded ends for my bars, like with the lineend option for a line (http://sape.inf.usi.ch/quick-reference/ggplot2/lineend) ?
解决方案
Here is an example where the bars have rounded ends, used with geom_line (geom_path), serving as a minimal example.
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 )
这篇关于R-ggplot-geom_bar的四舍五入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文