annotation_scale( mapping = NULL, data = NULL, ..., plot_unit = NULL, bar_cols = c("black", "white"), line_width = 1, height = unit(0.25, "cm"), pad_x = unit(0.25, "cm"), pad_y = unit(0.25, "cm"), text_pad = unit(0.15, "cm"), text_cex = 0.7, text_face = ...
ggspatial 添加指北针和比例尺 我们使用ggspatial包的annotation_scale()和annotation_north_arrow()方法实现这两个重要地图要素的添加。具体代码如下: 代码语言:javascript 代码运行次数:0 运行 AI代码解释 library(ggspatial)china_province_gg<-ggplot()+geom_sf(data=china_pro)+geom_sf(data=nine_line)+annotation_...
annotation_north_arrow(location = "bl", which_north = "true", pad_x = unit(0.75, "in"), pad_y = unit(0.5, "in"), style = north_arrow_fancy_orienteering) + coord_sf(xlim = c(-102.15, -74.12), ylim = c(7.65, 33.97)) ## Scale on map varies by more than 10%, scale bar...
AI代码解释 library(ggspatial)ggplot()+geom_sf(data=china,fill="NA",size=1,color="black")+geom_sf(data=nine_line)+coord_sf(crs="+proj=laea +lat_0=40 +lon_0=104")+annotation_scale(location="bl")+# spatial-aware automagic north arrowannotation_north_arrow(location="tl",which_north="...
annotation_scale(location="br")+# 设置距离刻度尺 #annotation_north_arrow(location="tl",style = north_arrow_nautical( # fill=c("grey40","white"),line_col="grey20" #))+ labs(x=NULL,y=NULL)+ geom_sf(data=shp1,fill="#AFB3B3",size=0.4,color="gray71")+#添加地图边界 ...
scale_color_manual():手动修改颜色 a+geom_density() 1. 根据sex修改颜色,将sex映射给line颜色 a+geom_density(aes(color=sex)) 1. 修改填充颜色以及透明度 a+geom_density(aes(fill=sex), alpha=0.4) 1. 添加均值线以及手动修改颜色 a+geom_density(aes(color=sex))+ geom_vline(data=mu, aes(xinte...
添加文本,标签和注释(Adding Text, Label and Annotation) 翻转和反转X和Y轴(Flipping and Reversing X and Y Axis) 分面:在一个图形中绘制多个图(Faceting: Draw multiple plots within one figure) 修改图背景,长轴和短轴(Modifying Plot Background, Major and Minor Axis) ...
(x=x,xend=xend, y=y, yend=y, annotation=annotation)) + geom_signif(comparisons=list(c("S1", "S2")), annotations="***", y_position = 9.3, tip_length = 0, vjust=0.4) + scale_fill_manual(values = c("grey80...
把条形图按照Improved变量进行分组,设置每个分组的填充色,这通过aes(fill=Improved)来实现,每个分组的填充色依次是scale_color_manual()定义的颜色: ggplot(data=Arthritis, mapping=aes(x=Improved,fill=Improved))+geom_bar(stat="count",width=0.5)+scale_color_manual(values=c("#999999","#E69F00","#56...
p2+scale_fill_gradient2(low = scales::muted("red"),mid="white",high= scales::muted("blue"),midpoint=0)+theme(legend.position ="bottom")+guides(fill=guide_colorbar(title.position ="top",title.hjust =0.5,barwidth =20)) -> p3.1p5+annotation_custom(grob = ggpubr::get_legend(p3.1...