Skip to content
Back to formatted view

Raw Message

Message-ID: <20220731163758.135905a8@trisector>
Date: 2022-07-31T13:37:58Z
From: Ivan Krylov
Subject: how to plot with color according to factor keeping a fixed number of levels?
In-Reply-To: <CAMk+s2SN_BKk=q4n2Nub2n_a1K60nF++EuAUU1de7rv5gLQUPw@mail.gmail.com>

On Sun, 31 Jul 2022 15:26:14 +0200
Luigi Marongiu <marongiu.luigi at 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