I am trying to make a scatter plot that contains two sets of data. Consequently, this means that the axis title is quite long and requires to be over two lines. I am able to do this but it seems to be interfering with the spacing on another bit of text in the axis title that I need to be superscript.It is adding additional spacing separating this bit of text from the rest of the label. If anyone had any suggestions to rectify this I would be very grateful.
Below I have included the code I am using. The particular line I am having trouble with is: ylab(expression(paste("mean water temperature (°C) &\n mean total solar (W/", m^2, ")")))
. As I am a new user I was unable to post an image. I should mention I am fairly new to R so forgive the mess of code.
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)