geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "black")+ geom_vline(xintercept = c(-1.2,1.2), linetype = "dashed", color = "black")+ geom_point(aes(size = -log10(adj.P.Val), color = -log10(adj.P.Val)))+ scale_color_gradientn(values = seq(0,1,...
scale_color_gradientn(colors = map) print(p) 4. 细节优化 为了插图的美观,对坐标轴细节等进行美化,并按期刊所需分辨率、格式输出图片。 # 细节调整 p+scale_x_continuous(expand = c(0,0))+ # x坐标轴与绘图区域边缘的扩展量 scale_y_continuous(expand = c(0,0))+ # y坐标轴与绘图区域边缘的扩...
scale_color_my <- function(palette="main", discrete=TRUE, reverse=FALSE, ...){ pal <- my_pal(palette = palette, reverse = reverse) if (discrete){ discrete_scale("colour", paste0("my_", palette), palette = pal, ...) }else{ scale_color_gradientn(colours = pal(256), ...) }...
identity使用color变量对应的颜色,对离散型和连续型都有效 scale_color_gradient scale_color_gradient2发散颜色渐变(低-中-高) scale_color_gradientn 双色渐变 aaa=mpg aaa$cty<- aaa$cty-20 f <- ggplot(aaa, aes(cty, hwy))+ geom_point(aes(color=cty)) f + scale_colour_gradient(low = "green"...
ggplot2的参数(分别从图层,scale,坐标,facet和theme介绍) ggplot2有许多参数,可根据需求自行选取,具体参数详情可见https://ggplot2.tidyverse.org/reference/index.html 基础绘图:由ggplot(data,aes(x,y))+geom_开始,至少包含这三个组件,可以通过"+"不断的添加layers, scales, coords和facets。
p + scale_color_gradient2(low = "red", mid = "white", high = "blue") #使用R预设调色板 p + scale_color_gradientn(colours =rainbow(10)) distiller 使用ColorBrewer的颜色 #将ColorBrewer的颜色应用到连续变量上 p + scale_color_distiller(palette = "Spectral") ...
p + scale_color_gradient(low = "white", high = "black") #设置中间过渡色 p + scale_color_gradient2(low = "red", mid = "white", high = "blue") #使用R预设调色板 p + scale_color_gradientn(colours =rainbow(10)) distiller 使用ColorBrewer的颜色 ...
p + scale_color_gradientn(colours =rainbow(10)) #legeng展示指定标签 p + scale_color_gradient(...
ggplot(mpg, aes(displ, hwy, color = hwy)) geom_point() scale_color_gradient(low = '#132B43', high = '#56B1F7',guide='colourbar') 一幅从'#132B43'到'#56B1F7'的渐变点图 2、调用调色板颜色 scale_colour_brewer( ..., type = 'seq', palette = 1, direction = 1, aesthetics = ...
scale_colour_gradientn(colours=c("darkblue","blue","#0092FF","#00FF92","#49FF00","#FFDB00","#FF0000","red","darkred"))+ 得到下面的图像: 5.3为图像加上线性回归和对角线 geom_smooth(method = "lm",formula = y~x,color="black")+ ...