当前位置: 首页 > wzjs >正文

多语言企业网站模板海外免费网站推广有哪些

多语言企业网站模板,海外免费网站推广有哪些,做图库网站用什么系统软件,海南百度首页广告目录 热图无显著性 结果展示01&#xff1a; 热图显著性 结果展示02&#xff1a; ggplot2绘制三角热图 结果展示03&#xff1a; corrplot绘制三角热图 结果展示04: 热图无显著性 # 示例数据 data(mtcars) df <- mtcars# 计算相关矩阵 cor_matrix <- round(cor(df…

目录

热图无显著性

结果展示01:

热图+显著性

结果展示02:

ggplot2绘制三角热图

结果展示03:

corrplot绘制三角热图

结果展示04:


热图无显著性

# 示例数据
data(mtcars)
df <- mtcars# 计算相关矩阵
cor_matrix <- round(cor(df), 2)# reshape 成长格式
library(reshape2)
cor_df <- melt(cor_matrix)# 画热图
library(ggplot2)
ggplot(cor_df, aes(x = Var1, y = Var2, fill = value)) +geom_tile(color = "white") +  ## 用色块(tiles)来构造热图geom_text(aes(label = sprintf("%.2f", value)), color = "black", family = "Times New Roman", size = 4) +scale_fill_gradient2(low = "#67a9cf", mid = "white", high = "#ef8a62",midpoint = 0, limit = c(-1, 1), name = "Correlation") +labs(title = "", x = "", y = "") +theme_bw(base_size = 14) +theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1),text = element_text(family = "Times New Roman"),   panel.grid = element_blank())

结果展示01:


热图+显著性

install.packages(c("Hmisc", "reshape2", "ggplot2"))
library(Hmisc)      # 用于计算相关性 + p 值
library(reshape2)   # 数据转换
library(ggplot2)    # 可视化# 加载必要包
library(Hmisc)
library(reshape2)
library(ggplot2)# 示例数据
df <- mtcars# 1. 计算相关性矩阵和显著性
res <- rcorr(as.matrix(df))
r_mat <- res$r
p_mat <- res$P# 2. 转换为长格式
r_df <- melt(r_mat)
p_df <- melt(p_mat)# 3. 添加显著性标记
p_df$signif <- cut(p_df$value,breaks = c(-Inf, 0.001, 0.01, 0.05, Inf),labels = c("***", "**", "*", ""))# 4. 合并 r 和 p
plot_df <- merge(r_df, p_df, by = c("Var1", "Var2"))# 对角线的 p 值设为空
plot_df$signif[plot_df$Var1 == plot_df$Var2] <- ""# 5. 生成标签(相关系数 + 显著性)
plot_df$label <- paste0(sprintf("%.2f", plot_df$value.x), plot_df$signif)# 6. 绘制热图
ggplot(plot_df, aes(x = Var2, y = Var1, fill = value.x)) +geom_tile(color = "white") +geom_text(aes(label = label), family = "Times New Roman", size = 4) +scale_fill_gradient2(low = "#67a9cf", mid = "white", high = "#ef8a62",midpoint = 0, limit = c(-1, 1), name = "Correlation") +labs(title = "", x = "", y = "") +theme_minimal(base_size = 14) +theme(axis.text.x = element_text(angle = 45, hjust = 1),axis.text.y = element_text(),panel.grid = element_blank(),text = element_text(family = "Times New Roman"))

结果展示02:


ggplot2绘制三角热图

library(Hmisc)
library(reshape2)
library(ggplot2)# 准备数据
df <- mtcars
res <- rcorr(as.matrix(df))
r_mat <- res$r
p_mat <- res$P# 转长格式
r_df <- melt(r_mat, na.rm = FALSE)
p_df <- melt(p_mat, na.rm = FALSE)# 显著性标记
p_df$signif <- cut(p_df$value,breaks = c(-Inf, 0.001, 0.01, 0.05, Inf),labels = c("***", "**", "*", ""))# 合并
plot_df <- merge(r_df, p_df, by = c("Var1", "Var2"))
plot_df$signif[plot_df$Var1 == plot_df$Var2] <- ""
plot_df$label <- paste0(sprintf("%.2f", plot_df$value.x), plot_df$signif)# 只保留右上三角格子(包含对角线)
plot_df <- plot_df[as.numeric(plot_df$Var2) >= as.numeric(plot_df$Var1), ]# 构造对角线上方的变量名标签
diagonal_labels <- subset(plot_df, Var1 == Var2)
diagonal_labels$label <- as.character(diagonal_labels$Var1)
diagonal_labels$y_pos <- as.numeric(diagonal_labels$Var1) - 0.3  # 微微往上移# 绘图ggplot() +geom_tile(data = plot_df, aes(x = Var2, y = Var1, fill = value.x), color = "white") +geom_text(data = plot_df, aes(x = Var2, y = Var1, label = label), family = "Times New Roman", size = 4) +geom_text(data = diagonal_labels, aes(x = Var2, y = y_pos+1, label = label),family = "Times New Roman",  size = 4) +scale_fill_gradient2(low = "#67a9cf", high = "#ef8a62", mid = "white",midpoint = 0, limit = c(-1, 1), name = "Correlation",labels = scales::number_format(accuracy = 0.1)) +# coord_fixed() +  #  保持格子为正方形labs(title = "", x = "", y = "") +theme_minimal(base_size = 14) +expand_limits(y = max(as.numeric(plot_df$Var1)) + 1)+theme(axis.text.y = element_blank(),axis.ticks.y = element_blank(),axis.text.x = element_text(angle = 45, hjust = 1),panel.grid = element_blank(),text = element_text(family = "Times New Roman"),plot.title = element_text(hjust = 0.5))

结果展示03:

corrplot绘制三角热图

# 示例数据
df <- mtcars
cor_matrix <- cor(df)par(family = "Times New Roman")corrplot(cor_matrix,method = "square",        # 方格图type = "upper",           # 只显示上三角diag = TRUE,              # 显示对角线addCoef.col = "black",    # 显示相关系数数字number.cex = 0.7,         # 数值大小tl.col = "black",         # 标签颜色tl.cex = 0.8,             # 标签字体大小tl.srt = 45,              # x轴标签角度(支持 45°/60° 等)col = colorRampPalette(c("#67a9cf", "white", "#ef8a62"))(200),mar = c(0,0,2,0)          # 边距微调
)

结果展示04:

http://www.dtcms.com/wzjs/161210.html

相关文章:

  • 郑州网站建设培训班公司关键词seo
  • 医疗网站设计方案网站推广优化业务
  • 做二手货车网站公司海外建站
  • 做网站应该问客户什么需求百度竞价点击神器
  • 关键词带淘宝的网站不收录百度热搜关键词排行榜
  • 大学生兼职网站做ppt百度指数资讯指数
  • 设计本网站怎么样百度网盘登录首页
  • vs做的网站怎么发布百度权重是怎么来的
  • 住建部四库一平台seo如何优化一个网站
  • 做网站用什么电脑好天津seo推广软件
  • 怎么制作网站建设湘潭网站定制
  • 网站建设和微站建设的区别2024最火的十大新闻有哪些
  • 怎么建自己公司网站长尾关键词爱站
  • 徐州市建设工程信息服务平台福建百度seo排名点击软件
  • 用php做视频网站有哪些产品营销策划方案怎么做
  • 怎么查寻一个网站做的竞价合肥网站建设
  • 武汉做网站jw100百度小说排行
  • 佛山市做网站的公司优化疫情防控
  • 中国煤炭建设协网站免费seo关键词优化排名
  • 门户网站舆情怎么做销售渠道
  • 关键词和网站标题影藏seo推广什么意思
  • 昆明网页建站平台seo快排优化
  • 广州专业网站改版哪家好网站优化排名易下拉软件
  • 网站 视差滚动google关键词分析工具
  • 网站开发合同存在的缺陷全网营销思路
  • 湛江网站建设开发网店关键词怎么优化
  • wordpress左右滑动页面谷歌seo培训
  • wordpress自带编辑器企业网站seo服务
  • 如何做网站内页免费引流推广怎么做
  • 凡客网站建设怎么样日结app推广联盟