我正在尝试绘制温度,同时从以下链接获取代码: https ://cran.r-project.org/web/packages/ggjoy/vignettes/gallery.html
这里作者使用 y 轴作为月份轴,但我想使用 x 轴作为月份轴和 y 轴作为温度轴。
数据可以从以下链接下载: https ://drive.google.com/file/d/0ByOfjCmqEilLYndpOWJyZXhPVUk/view
代码如下:
enter code here
library(ggjoy)
library(hrbrthemes)
library(viridis)
setwd <- 'C:/Users/Data/'
weather.raw <- read.csv(file="nebraska-2016.csv", header=TRUE, sep=",")
weather.raw$month<-months(as.Date(weather.raw$Date))
weather.raw$months<-
factor(rev(weather.raw$month),levels=rev(unique(weather.raw$month)))
mins<-min(weather.raw$Min.TemperatureF)
maxs<-max(weather.raw$Max.TemperatureF)
ggplot(weather.raw, aes(x = months , y = Mean.TemperatureF, fill = ..y..)) +
geom_joy_gradient(scale = 1, rel_min_height = 0.01, gradient_lwd = 1.) +
scale_x_discrete(expand = c(0.01, 0)) +
scale_y_continuous(expand = c(0.01, 0)) +
scale_fill_viridis(name = "Temp. [°C]", option = "C") +
labs(title = 'Temperatures',
subtitle = 'Histogram of Mean Temperatures (°F) - 2016') +
theme_joy(font_size = 13, grid = TRUE) + theme(axis.title.x = element_blank())
它给出了以下错误。
FUN(X[[i]], ...) 中的错误:找不到对象“y”