ggplot(mpg, aes(x = displ, y = hwy, shape = shape_code)) + geom_point(size = 3,color = "#db6968") + scale_shape_identity() 需要注意这样使用默认没有图例 2、离散型变量颜色调整 (1)scale_shape_continuous() 这个函数真的存在吗?? (2)scale_shape_binned() 将连续变量分箱(bin)后映射...
通过实例和RCode从浅到深介绍ggplot2的语法。 1. 五脏俱全的散点图# Copy library(ggplot2)# 表明我们使用diamonds数据集,ggplot(diamonds)+# 绘制散点图: 横坐标x为depth, 纵坐标y为price, 点的颜色通过color列区分,alpha透明度,size点大小,shape形状(实心正方形),stroke点边框的宽度geom_point(aes(x=carat,...
(size = 3), notch = FALSE, notchwidth = 0.5, outlier.tagging = FALSE, outlier.label = NULL, outlier.coef = 1.5, outlier.shape = 19, outlier.color = "black", outlier.label.args = list(size = 3), outlier.point.args = list(), point.args = list(position = ggplot2::position_...
ggplot(data=iris)+geom_point(mapping=aes(x=Sepal.Length,y=Petal.Length,color=Species),shape=24,fill="black")#24号,双色的例子 代码语言:javascript 代码运行次数:0 运行 AI代码解释 ggplot(data=iris,mapping=aes(x=Species,y=Sepal.Width,color=Species))+geom_boxplot() 代码语言:javascript 代码运行...
ggplot(midwest,aes(percbelowpoverty))+geom_histogram(binwidth=1)+ylab('Counties')ggplot(midwest,aes(percbelowpoverty))+geom_histogram(aes(weight=poptotal),binwidth=1)+ylab('Populations') 可以看出引入人口变量之后,贫困率整体发生了变化 🌴6.3 数据分布图 ...
ggplot(heightweight,aes(x=ageYear,y=heightIn))+geom_point(shape=12,size=1.5) 1. 2. 3. 4. 二 散点图修改 1.基于某变量对数据分组 将分组变量(必须是分类变量)映射给shape和colour属性,下面还是以上面的例子为说明,并选择数据集中的sex作为分类变量。
my_packages<-c("maftools","data.table","RColorBrewer","paletteer","ggplot2","ggpubr","tidyverse","REdaS","ggrepel")tmp<-sapply(my_packages,function(x)library(x,character.only=T));rm(tmp,my_packages) 接着就是完整代码了: 代码语言:javascript ...
ggplot (sah, aes (x = ageYear, y = heightIn, shape = sex)) + # 散点图函数 geom_point () 1. 2. 3. 4. 运行结果: 说明:可自定义点形,共有大概36种点形可供选择。具体请参考R语言ggplot2手册。 映射连续型变量 本例选用如下测试数据集: ...
My code: ggplot(data = world) + geom_sf() + geom_point(data = lat_lon, aes(x = LON_DD83, y = LAT_DD83), size = 4, shape = 23, fill = "darkred") + coord_sf(xlim = c(-80, -65), ylim = c(40, 50), expand = FALSE) ...
ggplot(pcm, aes(x = variable, y = station)) + geom_point(aes(fill=value*100,size=value*100),alpha = 0.5, shape = 21) + coord_fixed(ratio=1) + labs( x= "month", y = "station", size = "Percentage", fill ="Percentage") + ...