我正在尝试制作温度图,一切正常,但我不知道如何使用固定的调色板.
其实我有这个:
rgb.palette <- colorRampPalette(c("blue","green","yellow","orange","red"),
space = "Lab")
image.plot(akima.smooth,
col = rgb.palette(NBR.COLORS),
main=main_title,
horizontal=TRUE,
axes=TRUE)
Run Code Online (Sandbox Code Playgroud)
这个解决方案有效,但绘制的颜色总是从蓝色到红色.
例如,如果地图上的最低温度为-10°C,则颜色为蓝色,但如果最低温度为+ 25°C,则另一个地图中的颜色也为蓝色.
如何定义固定颜色面板,例如:
-30°C => blue
-20°C => light blue
-10°C => dark green
0°C => green
10°C => yellow
Run Code Online (Sandbox Code Playgroud)
如果在地图1中最低温度是-20我想要"浅蓝色"而在地图2中如果最低温度是10°CI则想要"黄色"颜色.
我使用了这个解决方案:
col = colorRampPalette(c("darkmagenta","blue","green","yellow","orange","red"),
space="Lab")(NBR.COLORS)
breaks = c(seq(-35, 10, length.out=NBR.COLORS/2), 10,
seq(10, 35, length.out=NBR.COLORS/2))
image.plot(akima.smooth, col=col, breaks=breaks, main=main_title,
horizontal=TRUE,axes=TRUE);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3243 次 |
| 最近记录: |