【发布时间】:2022-01-01 08:21:42
【问题描述】:
我想绘制如下图所示的内容,但出现“stat_count() 只能具有 x 或 y 美学”的错误。所以我把它改成stat="identity"。但是结果和我在网上找的例子不一样。
网上找到的例子:
示例来自:https://sebastiansauer.github.io/percentage_plot_ggplot2_V2/
我的代码
geom_bar(aes(y=pct_change, fill=factor(Year)), stat="count")+
geom_text(aes( label = scales::percent(pct_change),
y= pct_change ), stat= "count", vjust = -.5) +
ylab("Avg Unit Price") +
facet_grid(~Type.of.Sale) +
scale_y_continuous(labels = scales::percent)
【问题讨论】: