R_handbook_作图专题
ggplot基本作图
1 条形图
library(ggplot2)
ggplot(biopics) + geom_histogram(aes(x = year_release),binwidth=1,fill="gray")

2 堆砌柱状图
ggplot(biopics, aes(x=year_release)) +geom_bar(aes(fill=subject_sex))

3 堆砌比例柱状图
ggplot(biopics, aes(x=year_release)) +geom_bar(aes(fill=subject_sex),position = 'fill')

4 马赛克图
library(vcd)
bio_ques_d <- biopics[,c(11,13)]
bio_ques_d$subject_race <- ifelse(is.na(bio_ques_d$subject_race ), "missing",ifelse(bio_ques_d$subject_race == "White","White", "nonwhite"))
biq_ques_d_table <- table(bio_ques_d$subject_race,bio_ques_d$subject_sex)
mosaicplot(biq_ques_d_table)
5 双散点图
process_var <- c('v32', 'v33', 'v34', 'v35', 'v36', 'v37')
for (i in c(1:6)){var_clean <- paste(process_var[i],'clean',sep = '_')data[,var_clean] <- ifelse(data[,process_var[i]] == 'trust completely',1,ifelse(data[,process_var[i]] == 'trust somewhat',2,ifelse(data[,process_var[i]] == 'do not trust very much',3,ifelse(data[,process_var[i]] == 'do not trust at all',4,NA))))
}
data$intp.trust <- rowSums(data[,c(438:443)],na.rm = TRUE)
data$intp.trust <- data$intp.trust/6
ggplot(data[data$country == 'Iceland',], aes(x=confidence, y=intp.trust, colour=v225)) + geom_point()

6 双密度图
ggplot(data=start_s_country_data) +geom_density(aes(x=residual,color=as.factor(v225),))## 自定义图例的情况
ggplot(data=data) +geom_density(aes(x=LW, color = "LW")) + geom_density(aes(x=LP, color = "LP")) + labs(title="") + xlab("Value") + theme(legend.title=element_blank(),legend.position = c(0.9, 0.9))

ggplot(data ) +geom_point(aes(x = No.education, y=Median.year.of.schooling)) + geom_smooth(aes(x = No.education, y=Median.year.of.schooling), method = 'lm') + theme_classic()
7 双折线图与多图展示
library(dplyr)
library(devtools)
library(cowplot)plot_grid(plot1,plot3,plot5,plot2,plot4,plot6,ncol=3,nrow=2)
bio_ques_f <- biopics[,c(4,11,13)]
bio_ques_f$subject_race <- ifelse(is.na(bio_ques_f$subject_race ), "missing",ifelse(bio_ques_f$subject_race == "White","White", "nonwhite"))planes <- group_by(bio_ques_f, year_release, subject_race, subject_sex)
bio_ques_f_summary <- summarise(planes, count = n())
planes <- group_by(bio_ques_f,year_release)
bio_ques_f_year<- summarise(planes,count_year = n())bio_ques_f_summary <- left_join(bio_ques_f_summary,bio_ques_f_year,c("year_release" = "year_release"))
bio_ques_f_summary$prop <- bio_ques_f_summary$count / bio_ques_f_summary$count_yeardata_missing_female <- subset(bio_ques_f_summary,with(bio_ques_f_summary,(subject_race == 'missing') & (subject_sex == 'Female')))
data_missing_male <- subset(bio_ques_f_summary,with(bio_ques_f_summary,(subject_race == 'missing') & (subject_sex == 'Male')))
data_nonwhite_female <- subset(bio_ques_f_summary,with(bio_ques_f_summary,(subject_race == 'nonwhite') & (subject_sex == 'Female')))
data_nonwhite_male <- subset(bio_ques_f_summary,with(bio_ques_f_summary,(subject_race == 'nonwhite') & (subject_sex == 'Male')))
data_white_female <- subset(bio_ques_f_summary,with(bio_ques_f_summary,(subject_race == 'White') & (subject_sex == 'Female')))
data_white_male <- subset(bio_ques_f_summary,with(bio_ques_f_summary,(subject_race == 'White') & (subject_sex == 'Male')))plot1 <- ggplot(data_missing_female)+geom_line(aes(x=year_release,y=count),color="red") + geom_line(aes(x=year_release,y=prop),color="blue") +labs(title="missing and female")
plot2 <- ggplot(data_missing_male)+geom_line(aes(x=year_release,y=count),color="red") + geom_line(aes(x=year_release,y=prop),color="blue") +labs(title="missing and male")
plot3 <- ggplot(data_nonwhite_female)+geom_line(aes(x=year_release,y=count),color="red") + geom_line(aes(x=year_release,y=prop),color="blue") +labs(title="nonwhite and female")
plot4 <- ggplot(data_nonwhite_male)+geom_line(aes(x=year_release,y=count),color="red") + geom_line(aes(x=year_release,y=prop),color="blue") +labs(title="nonwhite and male")
plot5 <- ggplot(data_white_female)+geom_line(aes(x=year_release,y=count),color="red") + geom_line(aes(x=year_release,y=prop),color="blue") +labs(title="white and female")
plot6 <- ggplot(data_white_male)+geom_line(aes(x=year_release,y=count),color="red") + geom_line(aes(x=year_release,y=prop),color="blue") +labs(title="white and male")plot_grid(plot1,plot3,plot5,plot2,plot4,plot6,ncol=3,nrow=2)
ggplot作图美化
1 标题居中
ggplot(data_selected, aes(x=AREA.NAME)) +geom_bar(aes(fill=year)) + labs(title = 'The bar plot of AREA.NAME') +theme_classic() + theme(plot.title = element_text(hjust = 0.5))
2 X轴标签旋转
ggplot(data_selected, aes(x=AREA.NAME)) +geom_bar(aes(fill=year)) + labs(title = 'The bar plot of AREA.NAME') +theme_classic() + theme(plot.title = element_text(hjust = 0.5)) + theme(axis.text.x=element_text(face="bold",size=8,angle=270,color="black"))
3 变更label名
ggplot(data=data) + geom_line(aes(x=index,y=data,group=line,color=result)) + theme_classic() + scale_colour_manual(values=c("red", "blue"), labels=c("lose", "win"))
ggforce
ggforce能对绘制的图增加聚类图层,包括圆形、椭圆形、方形能多种。
North_latitude <- c(47.5, 52.3, 54.8, 48.4, 54.2,54.8, 54.4, 48.8, 50.5, 52.7,46.5, 46.9, 45.1, 45.9, 50.7,48.5, 48.3, 48.1, 48.8, 49.4)
Elevation <- c(2, 1, 1, 2, 1,1, 1, 2, 2, 1,2, 2, 2, 2, 1,2, 2, 1, 1, 1)
Temperature <- c(39.27, 39.00, 38.35, 37.58, 39.38,39.05, 39.65, 38.66, 37.97, 40.10,37.05, 37.19, 36.92, 36.70, 38.01,37.26, 36.97, 36.95, 37.68, 37.55)
data <- data.frame(North_latitude = North_latitude,Elevation = Elevation,Temperature = Temperature)
data$Elevation <- as.factor(data$Elevation)
dim(data)
library(ggplot2)
library(ggforce)
ggplot(data=data,aes(x=North_latitude,y=Temperature,color=Elevation))+
geom_point()+
geom_mark_circle(aes(fill=Elevation),alpha=0.4)+
theme_classic() +
labs(title = 'The relationship between latitude and temperature') +theme(plot.title = element_text(hjust = 0.5))

地理位置图
library(ggplot2)
library(viridis)
library(cvTools)
library(dplyr)data <- read.csv("Reef_Check_with_cortad_variables_with_annual_rate_of_SST_change.csv")world_map <- map_data("world")
ggplot() + geom_polygon(data =world_map, aes(x=long, y = lat, group = group), fill="grey", alpha=0.3) +geom_point(data =data, alpha = 0.2, aes(y=Latitude.Degrees, x= Longitude.Degrees , size=Average_bleaching, color=Average_bleaching)) + scale_colour_viridis() + theme_minimal()

igraph网络图
library(igraph)webforum_graph <- webforum[webforum$Date > as.Date("2010-12-01"), ]
webforum_graph <- webforum_graph[webforum_graph$Date < as.Date("2010-12-31"), ]# generate node dataframe
AuthorID <- unique(as.numeric(webforum_graph$AuthorID))
ThreadID <- unique(as.numeric(webforum_graph$ThreadID))
name <- c(AuthorID, ThreadID)
type <- c(rep("Author", length(AuthorID)) , rep("Thread", length(ThreadID)))
webforum_node <- data.frame(name = name, type = type)# generate edge dataframe
webforum_graph <- webforum_graph[,c("AuthorID", "ThreadID")]# generate graph dataframe
graph <- graph_from_data_frame(webforum_graph, directed = FALSE, vertices=webforum_node) set.seed(30208289)plot(graph, layout= layout.fruchterman.reingold, vertex.size=10, vertex.shape="circle", vertex.color=ifelse(V(graph)$type == "Thread", "red", "blue"),vertex.label=NULL, vertex.label.cex=0.7, vertex.label.color='black', vertex.label.dist=0,edge.arrow.size=0.2, edge.width = 0.5, edge.label=V(graph)$year, edge.label.cex=0.5,edge.color="black")

相关文章:
R_handbook_作图专题
ggplot基本作图 1 条形图 library(ggplot2) ggplot(biopics) geom_histogram(aes(x year_release),binwidth1,fill"gray") 2 堆砌柱状图 ggplot(biopics, aes(xyear_release)) geom_bar(aes(fillsubject_sex)) 3 堆砌比例柱状图 ggplot(biopics, aes(xyear_rele…...
关于Python里xlwings库对Excel表格的操作(二十五)
这篇小笔记主要记录如何【如何使用xlwings库的“Chart”类创建一个新图表】。 前面的小笔记已整理成目录,可点链接去目录寻找所需更方便。 【目录部分内容如下】【点击此处可进入目录】 (1)如何安装导入xlwings库; (2…...
2024 年软件工程将如何发展
软件开发目前正在经历一场深刻的变革,其特点是先进自动化的悄然但显着的激增。这一即将发生的转变有望以前所未有的规模简化高质量应用程序的创建和部署。 它不是单一技术引领这一演变,而是创新的融合。从人工智能(AI) 和数字孪生技术,到植根…...
【Git】git基础
Git 命令 git config --globle user.name ""git config --globle user.email ""git config -lgit config --globle --unset []git add []git commit -m ""]git log//当行且美观 git log --prettyoneline//以图形化和简短的方式 git log --grap…...
Linux中账号和权限管理
目录 一.用户账号和组账号: 1.用户账号类型: 2.组账号类型: 3.系统区别用户的方法 : 4.用户账号文件: 二.Linux中账户相关命令: 1.useradd: 2.passwd: 3.usermod:…...
Resnet BatchNormalization 迁移学习
时间:2015 网络中的亮点: 超深的网络结构(突破1000层)提出residual模块使用Batch Normalization加速训练(丢弃dropout) 层数越深效果越好? 是什么样的原因导致更深的网络导致的训练效果更差呢…...
Unity检测地面坡度丨人物上坡检测
Unity检测地面坡度 前言使用 代码 前言 此功能为,人物在爬坡等功能时可以检测地面坡度从而完成向某个方向给力或者完成其他操作 使用 其中我们创建了脚本GradeCalculation,把脚本挂载到人物上即可,或者有其他的使用方式,可自行…...
SASS循环
<template><div><button class"btn type-1">默认按钮</button><button class"type-2">主要按钮</button><button class"type-3">成功按钮</button><button class"type-4">信息…...
Java超高精度无线定位技术--UWB (超宽带)人员定位系统源码
UWB室内定位技术是一种全新的、与传统通信技术有极大差异的通信新技术。它不需要使用传统通信体制中的载波,而是通过发送和接收具有纳秒或纳秒级以下的极窄脉冲来传输数据,从而具有GHz量级的带宽。 UWB(超宽带)高精度定位系统是一…...
系列十一、解压文件到指定目录
一、解压文件到指定目录 1.1、需求 Linux的/opt目录有一个文件zookeeper-3.4.11.tar.gz,我现在想把该文件解压至/usr/local/目录,那么应该怎么做呢? 语法:tar -zxvf xxx -C /usr/local/ tar -zxvf zookeeper-3.4.11.tar.gz -C /u…...
PHP Swoole Client
PHP常用socket创建TCP连接,使用CURL创建HTTP连接,为了简化操作,Swoole提供了Client类用于实现客户端功能,并增加了异步非阻塞模式,让用户在客户端也能使用事件循环。 作为客户端使用,Swoole Client可以在F…...
《QDebug 2023年12月》
一、Qt Widgets 问题交流 1. 二、Qt Quick 问题交流 1.Q_REVISION 标记的信号槽或者 REVISION 标记的属性,在子类中访问 Q_REVISION 是 Qt 用来做版本控制的一个宏。以 QQuickWindow 为例,继承后去访问 REVISION 标记的 opacity 属性或者 Q_REVISION…...
sklearn 中matplotlib编制图表
代码 # 导入pandas库,并为其设置别名pd import pandas as pd import matplotlib.pyplot as plt# 使用pandas的read_csv函数读取名为iris.csv的文件,将数据存储在iris_data变量中 iris_data pd.read_csv(data/iris.txt,sep\t)# 使用groupby方法按照&quo…...
【Docker-Dev】Mac M2 搭建docker的redis环境
Redis的dev环境docker搭建 1、前言2、官方文档重点信息提取2.1、创建redis实例2.2、使用自己的redis.conf文件。 3、单机版redis搭建4、redis集群版4.1、一些验证4.2、一些问题 结语 1、前言 本文主要针对M2下,相应进行开发环境搭建,然后做一个文档记录…...
docker +gitee+ jenkins +maven项目 (一)
jenkins环境和插件配置 文章目录 jenkins环境和插件配置前言一、环境版本二、jenkins插件三、环境安装总结 前言 现在基本都是走自动化运维,想到用docker 来部署jenkins ,然后jenkins来部署java代码,做到了开箱即用,自动发布代码…...
IDEA 开发中常用的快捷键
目录 Ctrl 的快捷键 Alt 的快捷键 Shift 的快捷键 Ctrl Alt 的快捷键 Ctrl Shift 的快捷键 其他的快捷键 Ctrl 的快捷键 Ctrl F 在当前文件进行文本查找 (必备) Ctrl R 在当前文件进行文本替换 (必备) Ctrl Z 撤…...
Ubuntu Desktop 死机处理
Ubuntu Desktop 死机处理 当 Ubuntu Desktop 死机时,除了长按电源键重启,还可以使用如下两种方式处理。 方式1:ctrlaltFn 使用 ctrl alt F3~F6: 切换到其他 tty 命令行。 执行 top 命令查看资源占用最多的进程,然后使用 kill…...
Hermite矩阵
Hermite矩阵 文章目录 Hermite矩阵一、正规矩阵【定义】A^H^矩阵【定理】 A^H^的运算性质【定义】正规矩阵、特殊的正规矩阵【定理】与正规矩阵酉相似的矩阵也是正规矩阵【定理】正规的上(下)三角矩阵必为对角矩阵【定义】复向量的内积【定理】Schmitt正交化 二、酉矩阵&#x…...
HTML 实操试题(二)
创建一个简单的HTML文档: 包含<!DOCTYPE html>声明。包含<html>标签,并设置lang属性为英语。包含<head>标签,其中包含<meta charset"UTF-8">和一个自定义的页面标题。包含<body>标签,其…...
MongoDB 面试题
MongoDB 面试题 1. 什么是MongoDB? MongoDB是一种非关系型数据库,被广泛用于大型数据存储和分布式系统的构建。MongoDB支持的数据模型比传统的关系型数据库更加灵活,支持动态查询和索引,也支持BSON格式的数据存储,这…...
7.4.分块查找
一.分块查找的算法思想: 1.实例: 以上述图片的顺序表为例, 该顺序表的数据元素从整体来看是乱序的,但如果把这些数据元素分成一块一块的小区间, 第一个区间[0,1]索引上的数据元素都是小于等于10的, 第二…...
连锁超市冷库节能解决方案:如何实现超市降本增效
在连锁超市冷库运营中,高能耗、设备损耗快、人工管理低效等问题长期困扰企业。御控冷库节能解决方案通过智能控制化霜、按需化霜、实时监控、故障诊断、自动预警、远程控制开关六大核心技术,实现年省电费15%-60%,且不改动原有装备、安装快捷、…...
《通信之道——从微积分到 5G》读书总结
第1章 绪 论 1.1 这是一本什么样的书 通信技术,说到底就是数学。 那些最基础、最本质的部分。 1.2 什么是通信 通信 发送方 接收方 承载信息的信号 解调出其中承载的信息 信息在发送方那里被加工成信号(调制) 把信息从信号中抽取出来&am…...
C# 类和继承(抽象类)
抽象类 抽象类是指设计为被继承的类。抽象类只能被用作其他类的基类。 不能创建抽象类的实例。抽象类使用abstract修饰符声明。 抽象类可以包含抽象成员或普通的非抽象成员。抽象类的成员可以是抽象成员和普通带 实现的成员的任意组合。抽象类自己可以派生自另一个抽象类。例…...
深入解析C++中的extern关键字:跨文件共享变量与函数的终极指南
🚀 C extern 关键字深度解析:跨文件编程的终极指南 📅 更新时间:2025年6月5日 🏷️ 标签:C | extern关键字 | 多文件编程 | 链接与声明 | 现代C 文章目录 前言🔥一、extern 是什么?&…...
【论文阅读28】-CNN-BiLSTM-Attention-(2024)
本文把滑坡位移序列拆开、筛优质因子,再用 CNN-BiLSTM-Attention 来动态预测每个子序列,最后重构出总位移,预测效果超越传统模型。 文章目录 1 引言2 方法2.1 位移时间序列加性模型2.2 变分模态分解 (VMD) 具体步骤2.3.1 样本熵(S…...
学习STC51单片机32(芯片为STC89C52RCRC)OLED显示屏2
每日一言 今天的每一份坚持,都是在为未来积攒底气。 案例:OLED显示一个A 这边观察到一个点,怎么雪花了就是都是乱七八糟的占满了屏幕。。 解释 : 如果代码里信号切换太快(比如 SDA 刚变,SCL 立刻变&#…...
视频行为标注工具BehaviLabel(源码+使用介绍+Windows.Exe版本)
前言: 最近在做行为检测相关的模型,用的是时空图卷积网络(STGCN),但原有kinetic-400数据集数据质量较低,需要进行细粒度的标注,同时粗略搜了下已有开源工具基本都集中于图像分割这块,…...
如何更改默认 Crontab 编辑器 ?
在 Linux 领域中,crontab 是您可能经常遇到的一个术语。这个实用程序在类 unix 操作系统上可用,用于调度在预定义时间和间隔自动执行的任务。这对管理员和高级用户非常有益,允许他们自动执行各种系统任务。 编辑 Crontab 文件通常使用文本编…...
vue3 daterange正则踩坑
<el-form-item label"空置时间" prop"vacantTime"> <el-date-picker v-model"form.vacantTime" type"daterange" start-placeholder"开始日期" end-placeholder"结束日期" clearable :editable"fal…...
