[R] color2D.matplot with anchored color scale
Jim Lemon
drjimlemon at gmail.com
Fri Jul 10 12:53:53 CEST 2015
Hi Phong,
This is a common problem with using color to represent numeric values.
What you want is a reference scale. Whenever you call color2D.matplot,
use the "cellcolors" argument to specify the colors of each cell. You
can directly call "color.scale" in this argument, using the "xrange"
argument of that function to ensure that the colors returned are
calculated for the full range:
color.scale(...,xrange=c(0,40),...)
Look at the second example in the help page for "barp" to see how this
is done. Notice that it doesn't matter that the actual data are in
proportions (0 to 1) and the legend is labelled in percentages (0 to
100). The data values are correctly colored for the entire scale,
although none of these values are at the endpoints.
Jim
On Fri, Jul 10, 2015 at 12:22 PM, Phong Nguyen <xphongvn at gmail.com> wrote:
> Hello Jim,
>
> I have a several matrices stored in allGrid <- list()
>
> I am using:
>
> color2D.matplot(grid, extremes = c("green", "red"), vcol = "black",
> nslices = 60, show.legend=TRUE,axes=FALSE,show.values=TRUE,
> xlab="Columns",ylab="Rows")
>
> for each of "grid" in "allGrid". Each "grid" is a matrix with element range
> from 0 to max number of allGrid, say 40.
>
> I want to plot many "grid" with color represents the number (density). But I
> cannot fix the color scale and anchor the maximum value to a fixed number.
>
> I have tried many things but nothing works.
>
> Just the extra is: I cannot make the color from green (small number) ->
> yellow (middle number) -> red (big number). Sometimes, the plot turns black
> and white.
>
> Please help me.
>
> Phong
>
>
More information about the R-help
mailing list