[英]Add the values on the columns in R
這是我使用的代碼,我想為標簽添加值
ggplot(Duration_df,aes(x=factor(duration),y=sessions,fill=sessions)) +
xlab('Duration') + ylab('Sessions') +
geom_bar(stat='identity',colour='black') +
scale_fill_gradient(low='red', high='green') +
ggtitle('Duration By Sessions') +
theme(axis.text.x=element_text(angle = -35))
取決於標簽本身。 如果您想擁有與sessions
相同的值,您可以使用下面的代碼。
ggplot(Duration_df,aes(x=factor(duration),y=sessions,fill=sessions)) +
xlab('Duration') + ylab('Sessions') +
geom_bar(stat='identity',colour='black') +
scale_fill_gradient(low='red', high='green') +
ggtitle('Duration By Sessions') +
theme(axis.text.x=element_text(angle = -35)) +
geom_text(aes(label=sessions))
有hjust
或vjust
參數用於標簽的垂直和水平調整。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.