[R] how to plot with color according to factor keeping a fixed number of levels?

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Sun Jul 31 15:37:58 CEST 2022


On Sun, 31 Jul 2022 15:26:14 +0200
Luigi Marongiu <marongiu.luigi using gmail.com> wrote:

> but since there is no Y==0, the colors are shifted because Z has only
> two levels.

You're almost there: you're already making Z a factor. Use factor(Z,
levels = c(-1, 0, 1)) to make a factor with a predefined range of
values.

-- 
Best regards,
Ivan



More information about the R-help mailing list