该函数命名方法通常是scale_aesthetics_continuous或scale_aesthetics_discrete,将函数命名中的aesthetics替换为相应的图形属性如colour,fill,size等,如下 p = qplot(mpg, wt, data =mtcars, colour = factor(cyl)) p scale_colour_discrete= scale_colour_brewer p 8.2.2 几何对象和统计变换 类似update_geom_default...
#直接传colour参数,注意比较scale_color_discrete p9 <- base_99 + lims(x = c(1, 7), y = c(10, 45), colour = c("c", "d", "e", "p", "r")) p10 <- base_08 + lims(x = c(1, 7), y = c(10, 45), colour = c("c", "d", "e", "p", "r")) p11 <- ggplot...
# guide = FALSE turn off legend for size 关闭size的图例 # scale_color_discrete(name="States") 设置离散颜色变量的图例 gg + scale_color_discrete(name="States") + scale_size_continuous(name = "Density", guide = FALSE) 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Warning message:...
scale_colour_discrete()/scale_colour_hue色轮周围均匀等距色 scale_colour_grey()灰度调色板 scale_colour_viridis_d()viridis调色板 scale_colour_brewer()ColorBrewer调色板 scale_colour_manual()自定义颜色 先看几个简单的例子: library(ggplot2)library(scales)library(cowplot)p<-ggplot(mtcars,aes(x=wt,y=...
scale_fill_gray() #灰度填充色 scale_fill_hue() #自定义画板填充色 scale_fill_brewer() #自定义画板填充色 scale_fill_manual() #自定义填充色 基于颜色属性: scale_colour_discrete() scale_colour_continuous() scale_colour_gradient() scale_colour_gray() ...
p=ggplot(mtcars%>%mutate(am=as.factor(am)))+geom_point(aes(mpg,disp,colour=am))## 更改 x 间隔为5p+scale_x_continuous(name="X name(distance = 10)",breaks=breaks_width(10))->p1 ## 更改 x 间隔为2p+scale_x_continuous(name="X name(distance = 2)",breaks=breaks_width(2))->p2 ...
scale_colour_discrete(breaks = c('A','B','C','D'), labels = c('W','X','Y','Z')) p 5. 设置图例标题和标签文字的大小、颜色 library(ggplot2) dt = data.frame(A = 1:10, B = c(2,21,6,18,9,25,13,15,10,3), C = c('A','C','A','B','C','D','A','C',...
scale_color_discrete(name = '') + theme(legend.direction = "horizontal", legend.position = "top") + stat_ellipse(type = "t", size = 1, geom = "polygon", alpha = 0.2, aes(fill = groups), level = 0.85) + stat_ellipse(type = "t", size = 1, aes(colour = groups), level ...
设定参数limits来修改坐标轴顺序scale_x_discrete(limits=c("trt1","ctrl","trt2"))如忽略因子中某些类别,则输入:limits=c("trt1","ctrl")反转因子顺序scale_x_discrete(limits=rev(levels(PlantGrowth$group)))# PlantGrowth$group为因子变量 4.5 设置坐标轴缩放比例 ...
scale_colour_manual() scale_fill_manual() scale_size_manual() scale_shape_manual() scale_linetype_manual() scale_alpha_manual() scale_discrete_manual() 3,坐标轴 标度是区分离散和连续变量的,标度用于将连续型、离散型和日期-时间型变量映射到绘图区域,以及构造对应的坐标轴。