Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何对Ggplot中的y轴进行排序?_R_Ggplot2 - Fatal编程技术网

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$QuestionNumber
Data$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(),但这仍然让我有点困惑。这可能是另一个变体答案。我需要检查一下。你应该在你的问题中添加数据以获得更准确的答案。不过,逻辑也没什么不同。这可能是另一个不同的答案。我需要检查一下。你应该在你的问题中添加数据以获得更准确的答案。不过,逻辑也不例外。