我想绘制一个等高线图,以显示响应比率为1的位置。 x轴为饱和度,y轴为温度,z为spA1与spA2之比
我可以在ggplot2中做到这一点,但我所有其他图形都在绘图中,我希望最终能够覆盖其他线条,并具有一个辅助轴,该图形确实表现良好。
这可以密谋吗?
我已经在ggplot 2中使用geom_raster和geom_contour(breaks = 1)进行了尝试,并且可以正常工作,但是我在使用add_trace(z = 1,type =“ scatter”,mode =“ line”)的情况下尝试了 只是到处都画出怪异的线条...
数据:https://www.dropbox.com/s/gjdr5uuys6tqswr/df.csv?dl=0
Ratio <-(spA1/spA2)
#this works
Ratio <- ggplot(Ratio, aes(x = Saturation, y = Temp, z =
Ratio, fill = Ratio)) + geom_raster(interpolate = T) +
geom_contour(breaks = 1, colour="black", size=1) + theme(plot.title
= element_text(size = 12)) +
scale_fill_gradientn(colors=c("red","white","blue"),
values=rescale(c(0,1, 3)))
#this doesn't work
Ratio <- plot_ly(Ratio, x = ~ Saturation, y = ~ Temp, z =
~Ratio, type="contour", colorbar = list(title = "Ratio"),
colorscale = list(
c(0,1,2),
c("red", "white", "blue"))) %>%
add_trace(z=1, type = "scatter", mode = "line")
有可能这样做吗?我想做一些这样的线,并用辅助轴将它们覆盖在图中。预先谢谢你!
答案 0 :(得分:0)
我知道了。是
colorscale = "RdBu", contours = list( start = 1, end = 1, coloring='heatmap',
coloring='lines'), line = list(color = 'black', width = 2)))