ggplot を使用して散布図の凡例としてカラーバー (青赤) をプロットしています。ただし、青と赤のバランスがとれたカラーバーを生成することはできません。次のコードは、外観上、青がほとんど含まれておらず、赤が多いという結果をもたらします。赤に比べて青の割合を増やす方法を提案してください。
library(ggplot2)
x_axis<-sample(1:55) #55 values
y_axis<-sample(100:154) # 55 values
plotName<-'Scatter plot with colorbar instead of discrete legend'
dat_1 <- data.frame(xvar = x_axis,
yvar = y_axis,
col1 = c(rep(seq(27), each=2),28) )
chart<-ggplot(dat_1, aes(x=xvar, y=yvar)) +
geom_point(shape=19, size=5, aes(colour = col1)) +
scale_colour_continuous(low = "blue", high = "red", space = "Lab",
guide = guide_colourbar(title.position = 'bottom',direction="horizontal",title="South-
North",title.hjust=0.5,ticks=FALSE)) +
labs(title=plotName)+
theme(legend.position = "bottom") +
scale_y_continuous(expression(atop('Net'~CO[2]~'Flux '~CO[2]~' (β)' ))) +
scale_x_continuous(expression(atop('Gross'~CO[2])))
print(chart)