Lazy loaded imagegeom_tile():构建热图 / 网格图的砖块图层

type
Post
status
Published
date
Aug 12, 2025
slug
ggplot2-geom-tile
summary
介绍 geom_tile() 在 ggplot2 中绘制热图/网格图的用法,包括基础绘制、调色、顺序控制及叠加数值标签的示例。
tags
R
ggplot2
category
📈 R Visionary
icon
password
comment
Show
geom_tile()ggplot2 用于绘制**二维块图(tile)**的函数,通常搭配 fill 映射使用,用来表达一个变量在二维网格中的强度(如表达量、频数、打分等)。

✅ 基本语法

参数
说明
x, y
瓷砖的中心位置
fill
填充色(通常映射数值)
color
边框颜色(默认 NA 不显示边框)
width
瓷砖宽度(默认自动)
height
瓷砖高度(默认自动)

📦 示例数据(伪热图)


💡 示例 1:基础热图

✅ 按表达量 expr 用颜色填充,构成 gene × sample 的热图网格。

💡 示例 2:添加边框 + 自定义调色


💡 示例 3:顺序控制(防止字符自动排序)


💡 示例 4:在 tile 上叠加数值标签

Prev
parse_double() vs parse_number()
Next
常用美学参数详解:position, fill, alpha 等
Loading...
Article List
Evan の Logbook
✨ Updates
🎨 Style Guide
🧠 Creative Resources
🗒️ Mind Notes
🧭 Knowbase
📘 SOPs
🩺 Medical Research
🛠️ Tech Chronicles
💰 Fortune Blueprint
📈 R Visionary
📊 Statistics
🖼️ BioVis