希望在我的x轴上的标签和条形图中的数字上添加美元符号。下面是我的代码和图表。
YTD_bar <-
ggplot(TYSales_LYSales, aes(x=as.character(FSCL_YR), y=SALES)) + geom_bar(stat="identity", fill="orange", color="grey40") + theme_bw() + coord_flip() +
geom_text(aes(x= as.character(FSCL_YR), y=0.01, label= SALES),
hjust=-0.8, vjust=-1, size=3,
colour="black", fontface="bold",
angle=360) + labs(title="D27 2020 YTD Sales v 2019 YTD Sales", x="Fiscal Year",y="Sales") + theme(plot.title=element_text(hjust=0.5))
YTD_bar
鳞包(具有GGPLOT2安装)具有方便dollar
和label_dollar()
用于将十进制值成货币功能。
请参阅帮助以了解可用于调整格式的可能选项。
library(ggplot2)
library(scales)
YTD_bar <-
ggplot(TYSales_LYSales, aes(x=as.character(FSCL_YR), y=SALES)) +
geom_bar(stat="identity", fill="orange", color="grey40") +
theme_bw() + coord_flip() +
geom_text(aes(x= as.character(FSCL_YR), y=0.01, label= dollar(SALES)),
hjust=-0.8, vjust=-1, size=3, colour="black", fontface="bold", angle=360) +
labs(title="D27 2020 YTD Sales v 2019 YTD Sales", x="Fiscal Year",y="Sales") +
theme(plot.title=element_text(hjust=0.5)) +
scale_y_continuous(labels = label_dollar())
YTD_bar
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句