Skip to content
Prev 386712 / 398502 Next

Error: Discrete value supplied to continuous variable

You setup your X & Y axis incorrectly.  in your call to ggplot you have:

g <-df %>%
  ggplot(aes(x=reorder(job,-span), y=span, fill=factor(job))) +

but in your call to geom_rect you are using a completely different set
of variables that is causing the error:

 geom_rect(aes(xmin = ID - w/2,
                xmax = ID + w/2,
                ymin = ymin,
                ymax = ymax,
                fill = factor(job)), alpha=0.25)

I changed the call to ggplot to at least have the same variables types
and got a plot out of it; is this what you were expecting:

  ggplot(aes(x=ID, y=ymin, fill=factor(job))) +



Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
On Mon, Dec 28, 2020 at 4:33 PM King, Barry <king at butler.edu> wrote:
Message-ID: <CAAxdm-7fy6VaGZpRGPbTsvT5x+x4FAitYfYNbJo_2hsP-dKpig@mail.gmail.com>
In-Reply-To: <DM6PR05MB48418D561D4603D5321D49C5B3D90@DM6PR05MB4841.namprd05.prod.outlook.com>