我正在尝试制作包含两组数据的散点图。因此,这意味着轴标题很长并且需要超过两行。我能够做到这一点,但它似乎干扰了轴标题中我需要上标的另一段文本的间距。它增加了额外的间距,将这一部分文本与标签的其余部分分开。如果有人有任何建议要纠正这一点,我将非常感激。
下面我已经包含了我正在使用的代码。我遇到问题的具体方法是:ylab(expression(paste("mean water temperature (°C) &\n mean total solar (W/", m^2, ")")))
。由于我是新用户,我无法发布图片。我应该提到我对R来说相当新,所以请原谅代码的混乱。
library(ggplot2)
library(gtable)
library(grid)
library(reshape2)
library(gridExtra)
p <- ggplot(kom, aes(Date,AvgTotSol.5d.decawatts)) +
stat_smooth(method="loess") +
geom_point(shape =4, size = 4, colour = "#339900") +
geom_smooth(colour = "#339900") +
scale_x_datetime(name="Date") +
scale_y_continuous() +
ylab(expression(paste("mean water temperature (°C) &\n mean total solar (W/", m^2, ")")))+
geom_point(aes(Date,WatTempAvg.5d), shape = 2, size = 4, colour = "#cc0000")+
geom_smooth(aes(Date,WatTempAvg.5d), colour = "#cc0000") +
theme_bw(base_size = 18, base_family = "") +
theme(plot.margin = unit(c(0.25, 12, 0.25, 2), "cm"))
k <- ggplot(kom, aes(Date,Fish.Lake.1)) +
stat_smooth(method="loess") +
geom_point(shape =0, size = 4, colour = "#000066") +
geom_smooth(colour = "#000066")+
scale_x_datetime(name="Date") +
scale_y_continuous()+
ylab(expression(paste("y axis")))+
theme_bw(base_size = 18, base_family = "") +
theme(plot.margin = unit(c(0.25, 12, 0.25, 2), "cm"))
grid.arrange(p, k, nrow = 2)