ggplot错误:geom_point未知颜色名称

时间:2020-09-27 17:45:00

标签: r ggplot2

我有一个df:

   text  cost type 
  <dbl> <dbl> <chr>
1     1    23 h    
2     2    12 p    
3     3     3 h    
4     4    14 p    
5     5    21 h    
6     6     6 p 

我正在尝试使用geom_point根据data1$type自动分配颜色。

ggplot(data1,(aes(x=reorder(text,-cost),y=(cost))))+geom_point(colour=data1$type)

但是我得到了错误:

Unknown colour name: h

似乎需要特定的颜色,但是我敢肯定情况并非如此。有没有一种方法可以根据我的类型列自动分配颜色?

0 个答案:

没有答案