在图中,我需要叠加三个热图,我想获得RGB颜色编码,以便第一个热图以红色表示,第二个以绿色表示,第三个以蓝色表示。重叠区域应该获得与三个热图的基础值相对应的RGB颜色(例如,如果所有三个热图具有最大值,则为白色)。
我设法使用以下功能执行此操作:
def get_colormap(levels):
assert levels > 0 and levels <= 16, "'levels' needs to be positive and not too high, max is 16"
rgb_colors = [[]]*((levels)**3)
W = float(levels-1)
for r in range(levels):
for g in range(levels):
for b in range(levels):
rgb_colors[b + levels*g + (levels**2)*r] = [float(r)/W,float(g)/W,float(b)/W,1.0] # black background
return mpl.colors.ListedColormap(rgb_colors, name="lrgb_cmap")
当我绘制三条重叠线热图线时,我得到了这个结果: 请注意,色图每个RGB通道有4个级别,因此总共64个级别
现在,我想用白色反转黑色,这样三个热图中任何具有空值的区域都是白色,而重叠热图的最大值应该是黑色。我应该如何反转上述功能中的颜色编码?
答案 0 :(得分:0)
我认为你应该能做到:
... 19 more
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route _processCadastro at: >>> To[http4://xxx.xxx.xxx.xxx/api/cid?bridgeEndpoint=true] <<< in route: Route(_processCadastro)[[From[direct:insertUser]] ... because of Failed to resolve endpoint: http4://xxx.xxx.xxx.xxx/api/cid?bridgeEndpoint=true due to: No component found with scheme: http4
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1071)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:1008)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3397)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3128)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:182)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2957)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2953)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2976)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2953)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2920)
at org.apache.camel.main.Main.doStart(Main.java:129)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.main.MainSupport.run(MainSupport.java:138)
at pe.gov.br.ati.Activator.start(Activator.java:14)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
... 24 more
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: http4://xxx.xxx.xxx.xxx/api/cid?bridgeEndpoint=true due to: No component found with scheme: http4
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:628)
at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:79)
at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:211)
at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:108)
at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:114)
at org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:62)
at org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:56)
at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:545)
at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:506)
at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:222)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1068)
... 41 more
255是最大代码,因此所有颜色应在此处反转。如果您只想切换黑色和白色,请在反转之前添加if语句检查以检查颜色是黑色还是白色,然后使用上述方法。