我正在ggplot2中产生的热图上绘制点。 document.getElementById('gr_1_input_4').addEventListener('click', function(){
document.getElementById("gr_1_option_4").checked = true;
});
是一个数据框,其中包含要在热图上绘制的点。变量<div class="checkbox-wrapper">
<label for="gr_1_option_4">
<input type="radio" id="gr_1_option_4" name="group1" value="">
Sonstiges:
<input type="text" id="gr_1_input_4" name="group1"/>
</label>
</div>
存储ggplot图片。
热图由此链接中的代码生成(由于文本限制,无法在此处发布)。此外,链接中还包含所有必需数据帧的可复制代码。
现在要在热图上叠加点,我使用下面的代码:
delta
出现错误:
错误:连续值提供给离散刻度。
如果我从上面的代码中删除了plt
,它将起作用。但是随着此代码的产生,我需要有颜色编码的点:
plt0 <- plt + geom_point(data = delta, aes(x = dP/100, y = dT, z = NULL, color = rcp, shape = future))
plt0
产生此错误的原因是什么?我该如何解决?
答案 0 :(得分:1)
这样可以吗?
plt <- ggplot() + geom_tile(data=new.data, aes(x = hh/100, y = tt, fill=W)) +
geom_contour(data=new.data, bins = 10,
aes(x = hh/100, y = tt, #color = ..level..,
z = floor(W)),
show.legend = FALSE) +
ylab("Change in temperature in degree Celsius") +
xlab("percentage change in precipitation") +
scale_fill_gradientn(name = "W (in m3/year)",
values = scales::rescale(quantile(new.data$W)),
limits = c(min(new.data$W),max(new.data$W)),
breaks = seq(round(min(new.data$W)/1000000)*1000000,
round(max(new.data$W)/1000000)*1000000,
(round(max(new.data$W)/1000000)*1000000-round(min(new.data$W)/1000000)*1000000)/3),
colors = rainbow(7), guide = "colorbar") +
scale_x_continuous(breaks = seq(-0.3,0.3, 0.1), label = scales::percent) +
scale_y_continuous(breaks = seq(-1, 6, 1)) +
ggtitle("Variation of average annual sediment production with \n temperature and precipitation")+
guides(fill = guide_colorbar(barwidth = 0.5, barheight = 10))
plt
plt +
geom_point(data = delta, aes(x = dP/100, y = dT,
color = rcp, shape = future))
答案 1 :(得分:0)