如果我使用ggplot2绘制连续数据图,该函数应该使用给定比例(在低和高之间)中的颜色作为边界颜色。
> scale_colour_continuous <- function(...) {
> ggplot2::scale_colour_gradient(..., low = "#FFFF00", high = "#3366FF",
> na.value = "#262626", aesthetics = "colour")不幸的是,我上面的代码似乎不能正常工作。我发现它非常有趣,因为对于绘图的填充来说,同样的事情在相同的参数(aesthetics = "fill")下工作得很好。这里我漏掉了什么?
发布于 2019-01-15 23:31:51
您不需要显式地调用ggplot2。如果需要,可以添加一条If语句来检查是否加载了ggplot2。这是按照要求工作的。
my_theme<-function(...){
scale_colour_gradient(..., low = "#FFFF00", high = "#3366FF",
na.value = "#262626", aesthetics = "colour")
}
library(tidyverse)
iris %>%
ggplot(aes(Sepal.Length,Petal.Length,col=Sepal.Length))+
geom_point()+
my_theme()#wanted to make a theme so don't mind the naming.https://stackoverflow.com/questions/54200691
复制相似问题