在ggplot2中,只能在一侧更改条的边界? (颜色,厚度) [英] In ggplot2, can borders of bars be changed on only one side? (color, thickness)
问题描述
有没有办法做到这一点?
ggplot(diamonds,aes(clarity))+ geom_bar()
另一种可能性是使用两套 geom_bar
。第一套,绿色的,稍高一点,偏右。我借用@Didzis Elferts的数据。
$ g $ p $ ggplot(data = df2)+
geom_bar(aes(x = as.numeric(清晰度)+ 0.1,y = V1 + 100),
width = 0.8,fill =green,stat =identity)+
geom_bar(aes(x = as.numeric (清晰度),y = V1),
width = 0.8,stat =identity)+
scale_x_continuous(name =clarity,
breaks = as.numeric(df2 $ clarity) ,
labels = levels(df2 $ clarity))+
ylab(count)
I know, 3D Barcharts are a sin. But i´m asked to do them and as a trade-off i suggested to only make a border with a slightly darker color than the bar´s on the top and the right side of the bar. Like that, the bars would have some kind of "shadow" (urgh) but at least you still would be able to compare them.
Is there any way to do this?
ggplot(diamonds, aes(clarity)) + geom_bar()
Another possibility, using two sets of geom_bar
. The first set, the green ones, are made slightly higher and offset to the right. I borrow the data from @Didzis Elferts.
ggplot(data = df2) +
geom_bar(aes(x = as.numeric(clarity) + 0.1, y = V1 + 100),
width = 0.8, fill = "green", stat = "identity") +
geom_bar(aes(x = as.numeric(clarity), y = V1),
width = 0.8, stat = "identity") +
scale_x_continuous(name = "clarity",
breaks = as.numeric(df2$clarity),
labels = levels(df2$clarity))+
ylab("count")
这篇关于在ggplot2中,只能在一侧更改条的边界? (颜色,厚度)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!