R 如何对Ggplot中的y轴进行排序?
我有以下代码:R 如何对Ggplot中的y轴进行排序?,r,ggplot2,R,Ggplot2,我有以下代码: library(ggplot2) theme_set(theme_classic()) g <- ggplot(EYAnmut_3rdParty, aes(QuestionNumber)) g + geom_bar(aes(fill=stemmed), width = 0.5) + theme(axis.text.x = element_text(angle=65, vjust=0.6)) + labs(title="Histogram Plot") 库(
library(ggplot2)
theme_set(theme_classic())
g <- ggplot(EYAnmut_3rdParty, aes(QuestionNumber))
g + geom_bar(aes(fill=stemmed), width = 0.5) +
theme(axis.text.x = element_text(angle=65, vjust=0.6)) +
labs(title="Histogram Plot")
库(ggplot2)
主题集(theme\u classic())
g在没有样本数据的情况下,使用著名的虹膜进行了说明:可以假设物种是问题编号
library(tidyverse)
iris %>%
arrange(desc(Species), Sepal.Length) %>%
ggplot(aes(fct_rev(fct_infreq(Species)), Sepal.Length, fill=Species)) +
geom_col() +
labs(x="Species")
在没有样本数据的情况下,使用著名的虹膜进行了说明:可以假设物种是问题编号
library(tidyverse)
iris %>%
arrange(desc(Species), Sepal.Length) %>%
ggplot(aes(fct_rev(fct_infreq(Species)), Sepal.Length, fill=Species)) +
geom_col() +
labs(x="Species")
Data$QuestionNumberData$QuestionNumber请编辑您的问题以删除图像数据。使用dput
添加数据y
轴为计数。我假设您要对fill
axis进行排序。fill轴(有“词干”)实际上由值“Yes”、“No”和“Maybe”组成。我认为将其分类是没有帮助的。如果不是这样,请告诉我。@Dinesh使用dput(head(df,20))
向您的问题中添加数据。@Nelson,我正在尽力添加dput(),但这仍然让我有点困惑。请编辑您的问题以删除图像数据。使用dput
添加数据y
轴为计数。我假设您要对fill
axis进行排序。fill轴(有“词干”)实际上由值“Yes”、“No”和“Maybe”组成。我认为将其分类是没有帮助的。如果不是,请告诉我。@Dinesh使用dput(head(df,20))
为您的问题添加数据。@Nelson,我正在尽力添加dput(),但这仍然让我有点困惑。这可能是另一个变体答案。我需要检查一下。你应该在你的问题中添加数据以获得更准确的答案。不过,逻辑也没什么不同。这可能是另一个不同的答案。我需要检查一下。你应该在你的问题中添加数据以获得更准确的答案。不过,逻辑也不例外。