r-ggplot-quickplot

上传 CSV 数据文件,自动生成 9 种常用 ggplot2 图表(散点图、柱状图、箱线图、折线图、直方图、分面图等)。零代码可视化,支持 Docker/Singularity 免安装运行。

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "r-ggplot-quickplot" with this command: npx skills add kenthompson2088/r-ggplot-quickplot

r-ggplot-quickplot

零代码 ggplot2 可视化工具 - 上传 CSV 数据,自动生成专业图表。

三种运行模式

模式适用场景优点
Docker 模式个人电脑/桌面简单易用,生态完善
Singularity 模式HPC/共享服务器无需 root,适合集群
本地模式有 R 环境零依赖,最轻量

Docker 模式(桌面/个人电脑)

前置要求

安装 Docker Desktop:https://www.docker.com/products/docker-desktop/

快速开始

前置要求

安装 Docker Desktop:https://www.docker.com/products/docker-desktop/

快速开始

# Windows
run_docker.bat input/sample_data.csv

# Linux/macOS
./run_docker.sh input/sample_data.csv

使用示例

# 使用示例数据
./run_docker.sh input/sample_data.csv

# 使用自定义数据
./run_docker.sh input/my_data.csv output/

# 指定输出目录
./run_docker.sh data.csv results

本地模式

1. 安装依赖

需要安装 R (>= 4.0) 和 ggplot2:

install.packages('ggplot2')

2. 准备数据

上传 CSV 文件到 input 目录。支持的列:

列名类型说明用途
x数值X轴变量散点图、折线图
y数值Y轴变量散点图、折线图
category文本分类变量 (A-E)柱状图、箱线图、分面图
value数值数值指标柱状图、箱线图、直方图
group文本分组 (Control/Treatment)散点图、分组折线图
time数值时间点折线图

2. 运行绘图

执行以下命令:

cd <skill-directory>
Rscript run_plot.R input/your_data.csv

3. 获取结果

图表自动保存到 output/ 目录:

文件图表类型说明
01_scatter_basic.png散点图基础散点图
02_scatter_advanced.png高级散点图带颜色、大小、分组
03_barplot_vertical.png柱状图按分类汇总的垂直柱状图
04_barplot_horizontal.png水平柱状图按值排序的水平柱状图
05_boxplot.png箱线图带数据点的箱线图
06_lineplot.png折线图分组时间序列折线图
07_histogram.png直方图数值分布直方图
08_facet.png分面图按分类分面的散点图
09_publication_style.png出版级图表300 DPI 出版风格

命令行参数

Rscript run_plot.R <input_file> [options]

参数说明

参数说明默认值
<input_file>输入 CSV 文件路径必填
--output-dir输出目录output
--dpi图片分辨率150
--width图片宽度 (英寸)8
--height图片高度 (英寸)6

使用示例

# 使用默认设置
Rscript run_plot.R input/sample_data.csv

# 自定义输出设置
Rscript run_plot.R input/my_data.csv --output-dir results --dpi 300 --width 10 --height 8

输入数据格式

最小数据要求

只需要 xy 两列即可生成散点图:

x,y
2.3,5.1
3.1,4.8
1.8,6.2

完整数据示例

x,y,category,value,group,time
2.3,5.1,A,23,Control,1
3.1,4.8,A,45,Treatment,1
1.8,6.2,B,12,Control,2
4.2,3.9,B,67,Treatment,2

注意事项

  • CSV 文件必须包含表头行
  • 支持中文字段名
  • 缺失值用 NA 表示
  • 日期格式建议使用 YYYY-MM-DD

图表配置 (config.yaml)

可以通过配置文件自定义图表样式:

# 图表类型设置
charts:
  scatter: true
  barplot: true
  boxplot: true
  lineplot: true
  histogram: true
  facet: true

# 样式设置
style:
  theme: minimal    # minimal, classic, bw, light
  palette: steelblue
  font_size: 12

# 输出设置
output:
  format: [png, pdf]  # 支持 png, pdf, svg
  dpi: 150
  width: 8
  height: 6

自动检测逻辑

脚本会自动检测输入数据的列,并生成适合的图表:

检测到的列自动生成的图表
x, y散点图
category, value柱状图、箱线图
time, value折线图
value (单列)直方图
多分类列分面图
group分组着色

输出示例

成功运行后会显示:

=== r-ggplot-quickplot 执行完成 ===
输入文件: input/sample_data.csv
输出目录: output/

生成的图表:
  ✓ 01_scatter_basic.png
  ✓ 02_scatter_advanced.png
  ✓ 03_barplot_vertical.png
  ✓ 04_barplot_horizontal.png
  ✓ 05_boxplot.png
  ✓ 06_lineplot.png
  ✓ 07_histogram.png
  ✓ 08_facet.png
  ✓ 09_publication_style.png

共生成 9 个图表文件
===============================

Docker 镜像构建与发布

构建本地镜像

# Linux/macOS
./build_docker.sh

# Windows
docker build -t r-ggplot-quickplot .

发布到 Docker Hub

# 设置用户名
export DOCKER_USERNAME=your_username

# 构建并推送
./build_docker.sh latest

使用预构建镜像

如果镜像已发布,用户可以直接使用:

docker pull your_username/r-ggplot-quickplot:latest

Singularity 模式(HPC/服务器集群)

适用于高校、科研机构等共享服务器环境。

前置要求

联系管理员在服务器上安装 Singularity,或在本地构建镜像后上传。

构建镜像

# 在有 Singularity 的环境中
singularity build r-ggplot-quickplot.sif Singularity.def

# 或使用构建脚本
./build_singularity.sh

使用示例

# 使用示例数据
./run_singularity.sh input/sample_data.csv

# 使用自定义数据
./run_singularity.sh input/my_data.csv output/

手动运行

singularity exec \
    --bind ./input:/app/input:ro \
    --bind ./output:/app/output \
    r-ggplot-quickplot.sif \
    Rscript /app/run_plot.R /app/input/data.csv --output-dir /app/output

本地模式依赖安装

首次使用时,如缺少 R 包会自动安装:

install.packages('ggplot2')

如需额外功能,可手动安装:

install.packages('ggpubr')      # 出版级图表
install.packages('patchwork')   # 多图组合
install.packages('ggthemes')    # 主题风格

故障排除

错误:缺少 ggplot2

Rscript -e "install.packages('ggplot2')"

错误:输入文件不存在

# 检查文件路径
ls -la input/sample_data.csv

错误:列名不匹配

确保 CSV 文件包含所需列,或检查列名是否拼写正确。

技术细节

  • R 版本: >= 4.0.0
  • ggplot2 版本: >= 3.5.0
  • 输出格式: PNG (默认), PDF, SVG
  • 编码: UTF-8

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

pipintama-charts

Create, fetch, share, or update hosted Pipintama Charts through the MCP server. Use when a user needs a line, bar, pie, or radar chart from text or structure...

Registry SourceRecently Updated
810Profile unavailable
Research

Data Report Generator — CSV/Excel to Word/PDF with Charts

Automatically analyze CSV or Excel files and generate professional data analysis reports with charts, summaries, and insights — output as Word (.docx) or PDF...

Registry Source
4291Profile unavailable
General

Table To Image

将 Markdown 表格转换为清晰图片。当用户说"表格看不清"、"生成图片"、"转成图片"时触发。

Registry SourceRecently Updated
4120Profile unavailable
General

Kaggle

Unified Kaggle skill. Use when the user mentions kaggle, kaggle.com, Kaggle competitions, datasets, models, notebooks, GPUs, TPUs, badges, or anything Kaggle...

Registry SourceRecently Updated
1.1K2Profile unavailable