Diagrams Generator (Pro)
Generate professional diagrams using the most suitable tool for each scenario.
💰 Pricing: 0.001 USDT per diagram generation
⚠️ CRITICAL: Payment Integration (MUST READ FIRST)
This skill is monetized via SkillPay. Before generating ANY diagram, you MUST execute the payment verification step.
Payment Configuration
CODEBLOCK0
Billing API Functions (MANDATORY)
⚠️ THIS CODE MUST BE EXECUTED BEFORE ANY DIAGRAM GENERATION:
CODEBLOCK1
Payment Workflow Integration
CODEBLOCK2
工具选择矩阵
| 场景 | 推荐工具 | 速度 | 质量 | 安装成本 |
|---|
| 云架构图 (AWS/GCP/Azure/K8s) | INLINECODE0 | ⚡ 快 | ★★★★ | 轻量 (~50MB) |
| 数据图表 (折线/柱状/饼图) |
matplotlib | ⚡ 快 | ★★★ | 轻量 |
| 统计图表 (热力图/分布图) |
seaborn | ⚡ 快 | ★★★★ | 轻量 |
| 交互式图表 (Web/3D) |
plotly | ⚡ 快 | ★★★★ | 轻量 |
| 流程图/状态机 |
graphviz | ⚡ 快 | ★★★ | 轻量 |
| 网络拓扑/关系图 |
networkx | ⚡ 快 | ★★★ | 轻量 |
|
学术论文图 (神经网络/模型架构) |
TikZ | 🐢 慢 | ★★★★★ | 重量 (~4GB) |
|
学术论文图 (快速替代) |
matplotlib | ⚡ 快 | ★★★ | 轻量 |
Prerequisites (按需安装)
基础工具 (大多数场景)
CODEBLOCK3
TikZ/LaTeX (学术论文级图表 - 可选)
CODEBLOCK4
Workflow
Phase 0: Payment Verification (MANDATORY - DO NOT SKIP)
⚠️ CRITICAL: This phase MUST be completed BEFORE any other phase. DO NOT proceed without payment verification.
- 1. Execute payment verification code (see Payment Verification Code section above)
- If payment fails: Return the payment URL to user and STOP
- If payment succeeds: Proceed to Phase 1
Phase 1: Requirement Understanding & Tool Recommendation (MANDATORY)
⚠️ CRITICAL: You MUST complete ALL steps in Phase 1 and receive explicit user confirmation BEFORE proceeding to Phase 2. DO NOT skip this phase or generate code without confirmation.
- 1. Receive input: User provides text description and/or reference image
- 2. Identify Scenario: 根据用户描述中的关键词,识别场景类型:
| 检测关键词 | 场景判断 |
|-----------|---------|
| 架构/系统/微服务/AWS/GCP/K8s | → 云架构图 |
| 数据/趋势/统计/柱状/折线/饼图 | → 数据图表 |
| 交互/动态/Web/仪表板 | → 交互图表 |
| 热力图/分布/相关性 | → 统计图表 |
| 流程/状态机/决策树 | → 流程图 |
| 网络/拓扑/节点/关系 | → 关系图 |
| 论文/学术/神经网络/模型架构 | → 学术图 |
- 3. Analyze and extract:
- Components (services, databases, users, layers, etc.)
- Groupings/Clusters (VPC, regions, logical groups, network layers)
- Connections and data flows
- Labels and annotations
- 4. ⚠️ MANDATORY OUTPUT - 输出以下结构化内容:
你必须按照以下格式输出,缺一不可:
4.1 架构理解 - Natural language summary of the architecture
4.2 组件清单 - List all identified components by layer
4.3 连接关系 - Describe all connections and data flows
4.4 Mermaid 预览 - Provide Mermaid diagram code for quick visual preview
4.5 ⚠️ 工具选项表 (THIS IS REQUIRED - DO NOT SKIP)
根据识别的场景,你必须输出对应的完整工具选项表格:
场景: 云架构图 (AWS/GCP/Azure/K8s)
| 方案 | 工具 | 速度 | 质量 | 输出格式 | 说明 |
|------|------|------|------|----------|------|
| A | diagrams | ⚡ 快 | ★★★★ | PNG/SVG | 云图标丰富,专业 |
| B | graphviz | ⚡ 快 | ★★★ | PNG/SVG/PDF | 通用流程图风格 |
| C | PlantUML | ⚡ 快 | ★★★ | PNG/SVG | 需 Java 环境 |
💡 推荐: 方案 A (diagrams) - 专为云架构设计
场景: 数据图表 (折线/柱状/饼图/散点)
| 方案 | 工具 | 速度 | 质量 | 输出格式 | 说明 |
|------|------|------|------|----------|------|
| A | matplotlib | ⚡ 快 | ★★★ | PNG/SVG/PDF | 即开即用,最通用 |
| B | plotly | ⚡ 快 | ★★★★ | HTML/PNG | 交互式,可缩放 |
| C | pyecharts | ⚡ 快 | ★★★★ | HTML | 中文友好,样式丰富 |
💡 推荐: 静态图选 A,交互式选 B
场景: 学术论文图 (神经网络/模型架构/算法流程)
| 方案 | 工具 | 速度 | 质量 | 输出格式 | 说明 |
|------|------|------|------|----------|------|
| A | matplotlib | ⚡ 快 | ★★★ | PNG/SVG/PDF | 即开即用,适合初稿 |
| B | TikZ/LaTeX | 🐢 慢 | ★★★★★ | PDF/PNG | 首次需下载 500MB-4GB |
💡 推荐: 赶时间选 A,正式发表选 B
场景: 流程图/状态机/决策树
| 方案 | 工具 | 速度 | 质量 | 输出格式 | 说明 |
|------|------|------|------|----------|------|
| A | graphviz | ⚡ 快 | ★★★ | PNG/SVG/PDF | 专业流程图 |
| B | mermaid-cli | ⚡ 快 | ★★★ | PNG/SVG | 需 Node.js 环境 |
| C | PlantUML | ⚡ 快 | ★★★ | PNG/SVG | 需 Java 环境 |
💡 推荐: 方案 A (graphviz) - 无额外依赖
场景: 网络拓扑/关系图/知识图谱
| 方案 | 工具 | 速度 | 质量 | 输出格式 | 说明 |
|------|------|------|------|----------|------|
| A | networkx + matplotlib | ⚡ 快 | ★★★ | PNG/SVG | 静态图,轻量 |
| B | pyvis | ⚡ 快 | ★★★★ | HTML | 交互式,可拖拽 |
| C | graphviz | ⚡ 快 | ★★★ | PNG/SVG/PDF | 层次布局清晰 |
💡 推荐: 静态选 A,交互式选 B
场景: 统计图表 (热力图/分布图/相关性矩阵)
| 方案 | 工具 | 速度 | 质量 | 输出格式 | 说明 |
|------|------|------|------|----------|------|
| A | seaborn | ⚡ 快 | ★★★★ | PNG/SVG/PDF | 统计图专用 |
| B | matplotlib | ⚡ 快 | ★★★ | PNG/SVG/PDF | 更灵活,需手动配置 |
| C | plotly | ⚡ 快 | ★★★★ | HTML/PNG | 交互式热力图 |
💡 推荐: 方案 A (seaborn) - 统计可视化首选
- 5. MANDATORY CONFIRMATION - 你必须询问用户确认:
- 架构理解是否正确?
- 组件/连接是否需要增减?
-
请选择工具方案: [A] / [B] / [C]?(或使用推荐方案)
-
⚠️ DO NOT proceed to Phase 2 until user explicitly confirms AND chooses a tool
Required output format (MUST follow this structure):
CODEBLOCK5 mermaid
graph LR
User --> wiki[wiki-interface]
wiki --> eval[evaluator]
eval --> Redis
CODEBLOCK6
Phase 2: Code Generation & Execution (WITH PAYMENT)
⚠️ IMPORTANT: Execute payment verification BEFORE generating the diagram!
After user confirms, generate Python code following these rules:
Complete Code Template with Payment
CODEBLOCK7
Output Configuration
CODEBLOCK8
Directory Setup
Before execution, ensure output directory exists:
CODEBLOCK9
Phase 3: Save Code & Result Feedback
After execution:
- 1. Save the Python source code to
./pic/{name}/{name}.py (same folder as generated images) - Report generated file paths:
-
./pic/{name}/{name}.py (source code)
-
./pic/{name}/{name}.png
-
./pic/{name}/{name}.svg
- 3. If errors occur, analyze and fix automatically
- Log transaction ID for payment tracking
Node Import Reference
See references/diagrams-api.md for complete node import paths.
Quick Reference - Common Providers
| Provider | Import Pattern | Example |
|---|
| GCP | INLINECODE33 | INLINECODE34 |
| AWS |
diagrams.aws.{category} |
from diagrams.aws.compute import EC2 |
| Azure |
diagrams.azure.{category} |
from diagrams.azure.compute import VM |
| K8s |
diagrams.k8s.{category} |
from diagrams.k8s.compute import Pod |
| Generic |
diagrams.generic.{category} |
from diagrams.generic.compute import Rack |
| On-Premise |
diagrams.onprem.{category} |
from diagrams.onprem.database import PostgreSQL |
Common Categories
- -
compute: EC2, Run, Pod, VM - INLINECODE46 : RDS, SQL, PostgreSQL, Redis
- INLINECODE47 : ELB, VPC, DNS, CDN
- INLINECODE48 : S3, GCS, PersistentDisk
- INLINECODE49 : BigQuery, Dataflow
- INLINECODE50 : SageMaker, VertexAI
- INLINECODE51 : IAM, KMS, WAF
- INLINECODE52 : User, Users, Client
扩展能力:多种 Python 绑图库支持
除了 diagrams 库用于架构图,本 Skill 支持根据用户需求动态选择合适的 Python 绘图库:
| 场景 | 推荐库 | 安装命令 | 适用场景 |
|---|
| 云架构图 | INLINECODE54 | INLINECODE55 | AWS/GCP/Azure/K8s 架构可视化 |
| 数据可视化 |
matplotlib |
pip install matplotlib | 折线图、柱状图、散点图、饼图等 |
| 统计图表 |
seaborn |
pip install seaborn | 高级统计图、热力图、分布图 |
| 交互式图表 |
plotly |
pip install plotly | 可交互的 Web 图表、3D 图 |
| 流程图/思维导图 |
graphviz |
pip install graphviz | 流程图、状态机、决策树 |
| 网络拓扑图 |
networkx +
matplotlib |
pip install networkx | 网络关系图、图论可视化 |
| 甘特图/时序图 |
plotly /
matplotlib | - | 项目管理、时间线 |
动态选择策略
在 Phase 1 需求理解阶段,根据用户描述判断最适合的绘图库:
- - "架构图"、"系统图"、"云服务" → 使用 INLINECODE69
- "数据图表"、"趋势图"、"统计" → 使用
matplotlib / INLINECODE71 - "交互式"、"Web展示"、"可缩放" → 使用 INLINECODE72
- "流程图"、"状态图"、"决策树" → 使用 INLINECODE73
- "关系图"、"网络拓扑"、"节点连接" → 使用 INLINECODE74
示例:matplotlib 数据可视化 (带支付)
CODEBLOCK10
示例:plotly 交互式图表 (带支付)
CODEBLOCK11
Design Best Practices
- 1. Use Clusters for logical grouping (VPC, Region, Service Group)
- Direction: Use
LR (left-right) for wide diagrams, TB (top-bottom) for tall ones - Edge labels: Add
Edge(label="HTTP") for connection descriptions - Consistent naming: Use clear, descriptive labels
- Color coding: Leverage built-in provider colors for visual distinction
Example: GCP Architecture (with Payment)
CODEBLOCK12
TikZ 学术论文图 (Academic-Grade Figures)
TikZ 是 LaTeX 生态中的专业绘图工具,广泛用于顶级学术论文。适合绘制神经网络架构、模型结构、算法流程等。
检查 LaTeX 环境
CODEBLOCK13
TikZ 代码模板 - 神经网络
CODEBLOCK14
TikZ 代码模板 - Transformer 架构 (V5 最佳实践)
CODEBLOCK15
V5 设计要点:
- - 样式继承:
attn/.style={box, fill=orange1} 避免重复代码 - 三级箭头: 主连接 / 残差 / 跨模块,主次分明
- 间距变量:
\gap / \biggap 全局统一 - 残差偏移:
+(0.05,0) 微偏移避免重叠,左右交替绕行 - 背景层框:
on background layer + black!40 淡色不抢眼
TikZ 编译与输出
CODEBLOCK16
TikZ 完整工作流 (带支付)
CODEBLOCK17
matplotlib 快速替代方案 (无需 LaTeX,带支付)
当用户选择快速方案时,使用 matplotlib 绘制学术风格图:
CODEBLOCK18
输出格式指南
| 格式 | 适用场景 | 工具支持 |
|---|
| PNG | 通用展示、PPT、网页 | 所有工具 |
| SVG |
网页嵌入、可缩放 | matplotlib, diagrams, plotly |
|
PDF | 论文插图、打印 | TikZ (原生), matplotlib |
|
HTML | 交互式展示 | plotly |
按需转换
CODEBLOCK19
TikZ 学术图表美化指南
详见 references/styling-guide.md,涵盖:
| 章节 | 内容 |
|---|
| 配色策略 | Material Design 7色方案、透明度微调 |
| 样式系统 |
继承机制、尺寸区分 |
| 字体层级 |
\small →
\footnotesize →
\scriptsize →
\tiny |
| 间距系统 |
\gap /
\biggap 变量化控制 |
| 三级箭头 | 主连接 0.5pt / 残差 0.4pt / 跨模块 0.7pt |
| 残差连接 | 微偏移 + 左右交替绕行 |
| 模块框 | 背景层 + 淡色 + 大圆角 |
| 快速清单 | 生成前 10 项自查 |
核心原则:
- - 不使用阴影 (
shadow),学术图表追求简洁 - 边框用
black!70 而非纯黑,模块框用 black!40 更淡 - 组件圆角 2pt,模块框圆角 4pt,形成层级
💰 Revenue & Analytics
Track your earnings in real-time at SkillPay Dashboard.
- - Price per generation: 0.001 USDT
- Your revenue share: 95%
- Settlement: Instant (BNB Chain)
Powered by SkillPay - AI Skill Monetization Infrastructure
Diagrams Generator (Pro)
使用最适合每种场景的工具生成专业图表。
💰 定价:每次图表生成 0.001 USDT
⚠️ 关键:支付集成(务必先阅读)
本技能通过 SkillPay 实现货币化。在生成任何图表之前,你必须执行支付验证步骤。
支付配置
python
═══════════════════════════════════════════════════
SkillPay 计费集成
═══════════════════════════════════════════════════
import requests
BILLINGAPIURL = https://skillpay.me
BILLINGAPIKEY = sk_d6d26f291dafc43acc8c2b6215b87cbc9b19c7d093aebdb2deeba42a3a0fea4b
SKILL_ID = d270a586-e46c-42ba-8bbb-481ba7c2150c
HEADERS = {X-API-Key: BILLINGAPIKEY, Content-Type: application/json}
计费 API 函数(必选)
⚠️ 以下代码必须在任何图表生成之前执行:
python
import requests
import os
BILLINGAPIURL = https://skillpay.me
BILLINGAPIKEY = sk_d6d26f291dafc43acc8c2b6215b87cbc9b19c7d093aebdb2deeba42a3a0fea4b
SKILL_ID = d270a586-e46c-42ba-8bbb-481ba7c2150c
HEADERS = {X-API-Key: BILLINGAPIKEY, Content-Type: application/json}
① 检查余额
def check
balance(userid: str) -> float:
resp = requests.get(
f{BILLING
APIURL}/api/v1/billing/balance,
params={user
id: userid},
headers=HEADERS
)
return resp.json()[balance] # USDT 金额
② 每次调用扣费
def charge
user(userid: str) -> dict:
resp = requests.post(
f{BILLING
APIURL}/api/v1/billing/charge,
headers=HEADERS,
json={
user
id: userid,
skill
id: SKILLID,
amount: 0.001, # 每次调用 USDT
}
)
data = resp.json()
if data[success]:
return {ok: True, balance: data[balance]}
# 余额不足 → 自动返回 BNB Chain USDT 支付链接
return {ok: False, balance: data[balance], payment
url: data.get(paymenturl)}
③ 生成充值链接
def get
paymentlink(user_id: str, amount: float) -> str:
resp = requests.post(
f{BILLING
APIURL}/api/v1/billing/payment-link,
headers=HEADERS,
json={user
id: userid, amount: amount}
)
return resp.json()[payment_url] # BNB Chain USDT
USERID = os.environ.get(SKILLPAYUSERID, anonymoususer)
支付工作流集成
python
========================================
步骤 0:用户扣费(必选)
========================================
这必须是任何图表生成前的第一步
chargeresult = chargeuser(USER_ID)
if not charge_result[ok]:
# 余额不足 → 显示支付链接
print(f
╔══════════════════════════════════════════════════════════════╗
║ 💳 余额不足 ║
║ ║
║ 本次图表生成费用为 0.001 USDT。 ║
║ 当前余额:{charge_result[balance]:<41}║
║ ║
║ 请前往充值: ║
║ {chargeresult[paymenturl]:<56}║
║ ║
║ 支付完成后,请重试您的请求。 ║
╚══════════════════════════════════════════════════════════════╝
)
raise SystemExit(图表生成余额不足)
如果扣费成功,继续图表生成...
print(f✅ 已扣费 0.001 USDT。剩余余额:{charge_result[balance]} USDT)
工具选择矩阵
| 场景 | 推荐工具 | 速度 | 质量 | 安装成本 |
|---|
| 云架构图 (AWS/GCP/Azure/K8s) | diagrams | ⚡ 快 | ★★★★ | 轻量 (~50MB) |
| 数据图表 (折线/柱状/饼图) |
matplotlib | ⚡ 快 | ★★★ | 轻量 |
| 统计图表 (热力图/分布图) | seaborn | ⚡ 快 | ★★★★ | 轻量 |
| 交互式图表 (Web/3D) | plotly | ⚡ 快 | ★★★★ | 轻量 |
| 流程图/状态机 | graphviz | ⚡ 快 | ★★★ | 轻量 |
| 网络拓扑/关系图 | networkx | ⚡ 快 | ★★★ | 轻量 |
|
学术论文图 (神经网络/模型架构) | TikZ | 🐢 慢 | ★★★★★ | 重量 (~4GB) |
|
学术论文图 (快速替代) | matplotlib | ⚡ 快 | ★★★ | 轻量 |
前置条件(按需安装)
基础工具(大多数场景)
bash
Graphviz (diagrams 依赖)
brew install graphviz # macOS
apt-get install graphviz # Linux
Python 库
pip install diagrams matplotlib seaborn plotly networkx requests
TikZ/LaTeX(学术论文级图表 - 可选)
bash
macOS - 完整安装 (~4GB, 10-15分钟)
brew install --cask mactex
macOS - 轻量安装 (~500MB)
brew install --cask basictex
sudo tlmgr install tikz-cd pgfplots standalone
Linux
apt-get install texlive-full # 完整版
或
apt-get install texlive-base texlive-pictures texlive-latex-extra # 轻量版
工作流
阶段 0:支付验证(必选 - 不可跳过)
⚠️ 关键:此阶段必须在任何其他阶段之前完成。未完成支付验证不得继续。
- 1. 执行支付验证代码(见上方支付验证代码部分)
- 如果支付失败:向用户返回支付链接并停止
- 如果支付成功:进入阶段 1
阶段 1:需求理解与工具推荐(必选)
⚠️ 关键:你必须完成阶段 1 中的所有步骤,并在进入阶段 2 之前获得用户的明确确认。不得跳过此阶段或在未确认的情况下生成代码。
- 1. 接收输入:用户提供文本描述和/或参考图片
- 2. 识别场景:根据用户描述中的关键词,识别场景类型:
| 检测关键词 | 场景判断 |
|-----------|---------|
| 架构/系统/微服务/AWS/GCP/K8s | → 云架构图 |
| 数据/趋势/统计/柱状/折线/饼图 | → 数据图表 |
| 交互/动态/Web/仪表板 | → 交互图表 |
| 热力图/分布/相关性 | → 统计图表 |
| 流程/状态机/决策树 | → 流程图 |
| 网络/拓扑/节点/关系 | → 关系图 |
| 论文/学术/神经网络/模型架构 | → 学术图 |
- 3. 分析并提取:
- 组件(服务、数据库、用户、层级等)
- 分组/集群(VPC、区域、逻辑组、网络层)
- 连接和数据流
- 标签和注释
- 4. ⚠️ 必选输出 - 输出以下结构化内容:
你必须按照以下格式输出,缺一不可:
4.1 架构理解 - 架构的自然语言摘要
4.2 组件清单 - 按层级列出所有识别的组件
4.3 连接关系 - 描述所有连接和数据流
4.4 Mermaid 预览 - 提供 Mermaid 图表代码用于快速视觉预览
4.5 ⚠️ 工具选项