Chr*_*ris 3 gradient r ggplot2
为什么不采用绿色?它保持蓝色......
require(ggplot2)
data(iris)
ggplot(iris,aes(Sepal.Length,Sepal.Width,col=Petal.Length,pch=Species,size=Petal.Width))+
scale_fill_gradient(low="green",high="darkgreen")+
ggtitle('Why so blue?')+geom_point()
Run Code Online (Sandbox Code Playgroud)
有什么建议?
你已经使用过了scale_fill_gradient(),但你aes()的颜色包含了一个颜色.试试吧scale_color_gradient().
data(iris)
ggplot(iris,aes(Sepal.Length,Sepal.Width,
col=Petal.Length,pch=Species,size=Petal.Width))+
scale_color_gradient(low="green",high="darkgreen")+
ggtitle('Now so green')+geom_point()
Run Code Online (Sandbox Code Playgroud)
输出:
说明:
是否使用scale_fill或scale_color由提供给ggplot代码的aes()部分的参数决定.颜色参数通常用于geom_point()和geom_line(); 例如,填充参数通常用于条形图中条形的颜色.