XChart
XChart copied to clipboard
HeatMap: Presumably symmetric colormap definition leads to unsymmetric legend
I want to compare relative errors in a HeatMapChart
. Positive and negative relative errors of the same amount should have the same color coding. Therefore, I created a symmetric color definition for HeatMapStyler
and applied them with setRangeColors
.
Color[] colors = new Color[]{
new Color(0.0f,0.5f,1.0f)
,new Color(0.0f,0.5f,0.9f)
,new Color(0.0f,0.5f,0.8f)
,new Color(0.0f,0.5f,0.7f)
,new Color(0.0f,0.5f,0.6f)
,new Color(0.0f,0.5f,0.5f)
,new Color(0.0f,0.5f,0.4f)
,new Color(0.0f,0.5f,0.3f)
,new Color(0.0f,0.5f,0.2f)
,new Color(0.0f,0.5f,0.1f)
,new Color(0.0f,0.5f,0.0f)
//,new Color(0.0f,0.5f,0.0f)
,new Color(0.0f,0.5f,0.1f)
,new Color(0.0f,0.5f,0.2f)
,new Color(0.0f,0.5f,0.3f)
,new Color(0.0f,0.5f,0.4f)
,new Color(0.0f,0.5f,0.5f)
,new Color(0.0f,0.5f,0.6f)
,new Color(0.0f,0.5f,0.7f)
,new Color(0.0f,0.5f,0.8f)
,new Color(0.0f,0.5f,0.9f)
,new Color(0.0f,0.5f,1.0f)
};
The heat data ranges from the same absolute value from negative, to positive, so [-5.,...,5.] for example. I set these via setMin
and setMax
in the HeatMapStyler
. This basically works fine but what I found was, that the legend is unsymmetric. On the lower end the blue domain is larger than on the top end and the middle is shifted as well. In my actual application I use the Viridis
colormap definition where the problem is much more obvious for the yellow parts. I tried even and odd number of colors, but the result is the same.
Is that a problem on my end or with the way the legend is build?