In ggplot2 can borders of stripes be changed on one side only? (color, thickness)

I know 3D Barcharts is a sin. But I asked them to do it, and as a compromise, I suggested making only a border with a slightly darker color than on the top and right corner of the bar. Thus, the bars will have some kind of “shadow” (urgh), but at least you can still compare them.

Is there any way to do this?

ggplot(diamonds, aes(clarity)) + geom_bar() 
+2
source share
2 answers

Another possibility using two sets geom_bar. The first set, green, is made a little higher and is shifted to the right. I take 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")

enter image description here

+1
source

- 3D- "". ggplot2, .

, .

library(plyr)
df2<-ddply(diamonds,.(clarity),nrow) 

ggplot() clarity x V1 (counts) y geom_blank() - x . geom_rect() - xmin xmax as.numeric() clarity, ​​- xmin xmax . ymin 0 ymax V1 (counts) . geom_bar(stat="identity") , -.

ggplot(df2,aes(clarity,V1)) + geom_blank()+
  geom_rect(aes(xmin=as.numeric(clarity)-0.38,
                xmax=as.numeric(clarity)+.5,
                ymin=0,
                ymax=V1+250),fill="green")+
  geom_bar(width=0.8,stat="identity")

enter image description here

+2

All Articles