【发布时间】:2020-06-22 22:32:27
【问题描述】:
我使用 ggplot 创建了这个条形图。我必须创建自己的计数函数并将其命名为“a”,但现在该轴的标签只有一个 a,没有其他内容......我该如何解决?
a <- count(df, glass)
gl <- ggplot(df, aes(x=glass, y="a", fill=glass)) +
geom_bar(stat="identity") +
theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.5)) +
xlab("Glass type") +
ylab("Count") +
coord_flip() +
theme_minimal() +
theme(legend.position = "none")
gl
这是我的图表
【问题讨论】:
-
如果您包含一个简单的reproducible example,其中包含可用于测试和验证可能解决方案的示例输入和所需输出,则更容易为您提供帮助。
-
如果您希望 ggplot2 为您计算,请尝试使用
geom_bar()而不使用y,然后从栏层中删除stat = "identity"。