我知道3D条形图是一种罪过。但是我被要求这样做,但我需要权衡取舍,我建议只使边框的颜色比酒吧顶部和右侧的酒吧的颜色略深。像这样,这些条形会有某种“阴影”(阴影),但至少您仍然可以比较它们。
有什么办法吗?
ggplot(diamonds, aes(clarity)) + geom_bar()
最佳答案
另一种可能性是使用两组geom_bar
。第一组,绿色的,稍高一些,向右偏移。我从@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")