Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in ggplot2 density plot: "Error: Must request at least one colour from a hue palette."

Tags:

r

ggplot2

Having installed tidyverse, I can't get the following to work....

ggplot(iris, aes(x = Sepal.Length, fill = Species) + geom_density(alpha = .3)

The error reads: "Error: Must request at least one colour from a hue palette."

Any ideas?

like image 328
stixmcvix Avatar asked Dec 02 '22 11:12

stixmcvix


1 Answers

Just for the record and for future readers, I had this error related with the specific column (iris$Species in this example) containing only NAs.

This happened because some libraries did not work properly after sourcing my code, and therefore some tables didn't have the proper format.

like image 140
Carles Borredá Avatar answered Dec 29 '22 01:12

Carles Borredá