pythonic生物人

复现Science图,换数据即可用!

本次使用R语言复现一下Science正刊中的1张图!

doi/10.1126/science.adj6841,Fig.3 B原图
doi/10.1126/science.adj6841,Fig.3 B原图
❤️复现效果图-B图❤️
❤️复现效果图-B图❤️

✅读入测试数据,

Image

✅关键代码,

# 关键代码
treemap_set <- voronoiTreemap(
  data = voronoi_data,
  levels = c("Continent", "Income.group", "ISO3_value"), # 将 Continent 置于最前作为主要聚合维度
  cell_size = "Achievable.mitigation..Pg.C."
)

# 绘制最终图形
drawTreemap(
  treemap_set,
  color_palette = income_colors,
  label_size = 3,
  label_color = "white",
  border_color = "black",
  border_size = 3,
)

这个图代码非常简单,无需太多介绍,看效果,

Image

✅ Voronoi Treemap,这是一张Voronoi Treemap(沃罗诺伊树图)是一种结合了树图和沃罗诺伊图特点的数据可视化形式。它的核心作用是通过嵌套的不规则多边形来展示层次化数据,其中每个多边形的面积大小代表其对应数据的数值权重。

✅ 原文中,该图展示全球不同大洲(Continent)、收入组别(Income group)和国家(ISO3)可实现减缓潜力(Achievable.mitigation..Pg.C.)这一指标上的差异。结合原文,学习如何读这张图:

  • 🔸嵌套多边形结构,表示数据的层次关系,如一个大洲包含多个国家,红色箭头所指粗线表示大洲分界;蓝色箭头所指表示国家的分界。
Image
  • 🔸颜色,不同的颜色代表不同的Income group,如High income、Low income、Upper middle income等。

  • 🔸多边形面积,表示Achievable.mitigation..Pg.C.指标的数值大小,面积越大,潜力越高。

✅ 总之,通过这张图,可快速了解在全球范围内Achievable.mitigation..Pg.C.指标在不同大陆、收入群体和国家间的分布差异。


当然,对于可视化,我们可以尝试不同的colomap以符合自己审美,分享8组配色:

c( "Low income" = "#00A1B0","Lower middle income" = "#6EBF4B","Upper middle income" = "#E6C35C","High income" = "#DC8F42")、c( "Low income" = "#440154","Lower middle income" = "#31688E","Upper middle income" = "#35B779","High income" = "#FDE725")
c( "Low income" = "#00A1B0",
"Lower middle income" = "#6EBF4B",
"Upper middle income" = "#E6C35C",
"High income" = "#DC8F42"
)、c( "Low income" = "#440154",
"Lower middle income" = "#31688E",
"Upper middle income" = "#35B779",
"High income" = "#FDE725"
)
c( "Low income" = "#B2182B","Lower middle income" = "#EF8A62","Upper middle income" = "#67A9CF","High income" = "#2166AC")、c( "Low income" = "#FF0088", "Lower middle income" = "#0076CC", "Upper middle income" = "#FF7F00", "High income" = "#4DAF4A" )
c( "Low income" = "#B2182B",
"Lower middle income" = "#EF8A62",
"Upper middle income" = "#67A9CF",
"High income" = "#2166AC"
)、c( "Low income" = "#FF0088", "Lower middle income" = "#0076CC", "Upper middle income" = "#FF7F00", "High income" = "#4DAF4A" )
c( "Low income" = "#2CA02C", "Lower middle income" = "#1F77B4", "Upper middle income" = "#FF7F0E", "High income" = "#8A8A8A" )、c( "Low income" = "#4DBBD5", "Lower middle income" = "#00A1B0", "Upper middle income" = "#31688E", "High income" = "#74C476" )
c( "Low income" = "#2CA02C", "Lower middle income" = "#1F77B4", "Upper middle income" = "#FF7F0E", "High income" = "#8A8A8A" )、c( "Low income" = "#4DBBD5", "Lower middle income" = "#00A1B0", "Upper middle income" = "#31688E", "High income" = "#74C476" )
c( "Low income" = "#7F4BB1", "Lower middle income" = "#71D06E", "Upper middle income" = "#E78951", "High income" = "#E0C5F2" )、c( "Low income" = "#E53A40", "Lower middle income" = "#EFDC05", "Upper middle income" = "#30A9DE", "High income" = "#4B0082" )
c( "Low income" = "#7F4BB1", "Lower middle income" = "#71D06E", "Upper middle income" = "#E78951", "High income" = "#E0C5F2" )、c( "Low income" = "#E53A40", "Lower middle income" = "#EFDC05", "Upper middle income" = "#30A9DE", "High income" = "#4B0082" )

本期结束!


完整绘图代码+测试数据+数据处理方法+依赖包安装方法,

👇备注:299

图片
近期推文即将加入👉《保姆级R可视化教程4.0》来了!数百张图,旨在引导如何系统学习R语言可视化,部分展示如下:
图片
复现效果图-abcd图❤️
复现效果图-b图❤️
图片
❤️复现效果图-ABCD图❤️
图片
❤️复现效果图-bcd图❤️
图片
图片
❤️复现效果图-b图❤️
图片
图片
图片
图片
图片
图片
图片
图片
图片
图片

图片

图片
图片
图片

加入学习,备注:299

图片