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)