Evan の Logbook
✨ Updates
🎨 Style Guide
🧠 Creative Resources
🗒️ Mind Notes
🧭 Knowbase
📘 SOPs
🩺 Medical Research
🛠️ Tech Chronicles
💰 Fortune Blueprint
📈 R Visionary
📊 Statistics
🖼️ BioVis
ggthemr:为 ggplot2 一键换肤
type
Post
status
Published
date
Jul 25, 2025
slug
ggthemr
summary
使用 `ggthemr` 包创建并应用自定义与预设主题,让 `ggplot2` 图形快速拥有一致的色彩风格。
tags
R
ggplot2
ggthemr
category
📈 R Visionary
icon
password
comment
Show
简介ggthemr是一个为ggplot2提供主题和调色板的 R 包,可以加载预设风格,也能自定义任意色板,轻松为所有图表统一“皮肤”。
1. 安装与加载
2. 应用预设主题
- 预设主题包括
"fresh"、"pale"、"flat"、"dust"等十余种。
3. 自定义色板
swatch:离散色板
gradient:数值映射时使用的渐变色
4. 示例对比
5. 主题速查
主题名 | 说明 |
ggthemr("fresh") | 清新配色 |
ggthemr("dust") | 淡雅灰尘感 |
ggthemr("pale") | 柔和浅色 |
ggthemr("flat") | 扁平化风格 |
ggthemr_reset() | 恢复 ggplot2 默认 |
小结
ggthemr不仅提供多种预设主题,还能通过define_palette()自由定义色板;
- 一旦设置,后续所有
ggplot2绘图都会自动套用该主题;
- 完成图形后别忘了用
ggthemr_reset()恢复默认,避免影响其他可视化。
Prev
ggplot2 点形状
Next
ggthemes 常用主题
Loading...
YouTube 使用笔记