Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.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 GG绘制因子的反向轴顺序_R_Ggplot2_Ggridges - Fatal编程技术网

R GG绘制因子的反向轴顺序

R GG绘制因子的反向轴顺序,r,ggplot2,ggridges,R,Ggplot2,Ggridges,这是底图,月份从下到上排列从一到十二个月。我想从上到下从一点到十二点 library(tidyverse) library(nycflights13) library(ggridges) ggplot(weather %>% filter(temp > 50), aes(x = temp, y = as.factor(month))) + geom_density_ridges() 这两种解决方案都会产生错误。正确的解决方案是什么 # BROKEN SOLUTION 1

这是底图,月份从下到上排列从一到十二个月。我想从上到下从一点到十二点

library(tidyverse)
library(nycflights13)
library(ggridges)
ggplot(weather %>% filter(temp > 50), aes(x = temp, y = as.factor(month))) + 
  geom_density_ridges()

这两种解决方案都会产生错误。正确的解决方案是什么

# BROKEN SOLUTION 1    
ggplot(weather %>% filter(temp > 50), aes(x = temp, y = as.factor(month))) + 
  geom_density_ridges() + 
  scale_y_continuous(trans = "reverse")
错误:离散值提供给连续刻度。此外: 警告消息:1:在运算系数(x)中:“-”对于 因素。2:变换在连续模式中引入无穷大值 y轴

而且

# BROKEN SOLUTION 2
ggplot(weather %>% filter(temp > 50), aes(x = temp, y = as.factor(month))) + 
  geom_density_ridges() + 
  scale_y_discrete(limits = rev(levels(as.factor(month))))
is.factor(x)中出错:找不到对象“月”

尝试
scale\u y\u discrete(limits=rev)

尝试
scale\u y\u discrete(limits=rev)