固定颜色的特定值 [英] Fixed color for specific value

查看:194
本文介绍了固定颜色的特定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



实际上我有这个:

我试图制作一个温度图,一切正常,但我不知道如何有一个固定的调色板。 / p>

  rgb.palette<  -  colorRampPalette(c(blue,green,yellow,orange red),
space =Lab)

image.plot(akima.smooth,
col = rgb.palette(NBR.COLORS),
main = main_title,
horizo​​ntal = TRUE,
axes = TRUE)

工作,但被绘的颜色总是从蓝色到红色。



例如,如果地图上的最低温度为-10°C,颜色将为蓝色,但在另一张地图中,如果最低温度为+ 25°C

 


$ b

code> -30°C => blue
-20°C =>浅蓝色
-10℃=>深绿色
0℃=>绿色
10°C =>黄色

如果在地图1最低温度是-20我想要浅蓝色最低温度为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, length.out = NBR.COLORS / 2))
image.plot(akima.smooth,col = col,breaks = breaks,main = main_title,
horizo​​ntal = TRUE,axes = TRUE);


I am trying to make a temperature map, all works fine but I don't know how to have a fixed color palette.

Actually I have this :

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)

This solution works but the colors which are painted are always from blue to red.

For example if the lowest temperature on the map is -10°C the color will be blue, but in another map if the lowest temperature is +25°C that color will be blue too.

How can I define a fixed color panel such as :

-30°C => blue
-20°C => light blue
-10°C => dark green
  0°C => green
 10°C => yellow

If in map 1 lowest temperature is -20 I want "light blue" and in map 2 if lowest temperature is 10°C I want "yellow" color.

解决方案

I used this solution :

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);

这篇关于固定颜色的特定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆