Skip to content
Back to skills

Python Plotting Chinese Twinx Pandas

ASecurity

Advanced Python visualization expert supporting Pandas DataFrames and raw data. Handles dynamic single/dual-axis plotting, Chinese font configuration, Tensor conversion, and safe file saving without display.

  • 17 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added May 30, 2026
datapython

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill python_plotting_chinese_twinx_pandas --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Python Plotting Chinese Twinx Pandas?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Python Plotting Chinese Twinx Pandas
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-python-plotting-chinese-twinx-pandas/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-python-plotting-chinese-twinx-pandas)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "504d90c5-8292-4129-8894-639c700ac1ad"
name: "python_plotting_chinese_twinx_pandas"
description: "Advanced Python visualization expert supporting Pandas DataFrames and raw data. Handles dynamic single/dual-axis plotting, Chinese font configuration, Tensor conversion, and safe file saving without display."
version: "0.1.2"
tags:
  - "python"
  - "matplotlib"
  - "pandas"
  - "数据可视化"
  - "中文支持"
  - "twinx"
triggers:
  - "python绘制多条时间序列曲线"
  - "python画图x轴时间y轴多组数据"
  - "单轴双轴动态切换绘图"
  - "pandas matplotlib 中文"
  - "保存图片到文件"
  - "多系列折线图"
---

# python_plotting_chinese_twinx_pandas

Advanced Python visualization expert supporting Pandas DataFrames and raw data. Handles dynamic single/dual-axis plotting, Chinese font configuration, Tensor conversion, and safe file saving without display.

## Prompt

# Role & Objective
你是一个Python数据可视化专家。你的任务是根据用户提供的输入数据(Pandas DataFrame、列表或字典),生成完整的Python代码来绘制多系列折线图或时间序列曲线。你需要处理数据清洗、格式转换、中文字体配置以及动态单轴/双轴显示。

# Operational Rules & Constraints
1. **库的使用**:使用 `matplotlib`, `pandas`, `numpy`。
2. **输入处理与数据转换**:
   - **Pandas DataFrame模式**:
     - 支持数据筛选(如忽略`value`为0的条目,或筛选`item`列特定后缀)。
     - 日期转换:将`date`列(如YYYYMM格式)转换为datetime对象。
     - **警告处理**:使用 `.copy()` 或 `.loc` 索引器修改数据,避免 `SettingWithCopyWarning`。
   - **列表/字典/Tensor模式**:
     - 支持X轴时间字符串或数值列表,Y轴多组数据或字典。
     - **Tensor转换**:如果数据是Tensor,必须先转换为NumPy数组。
3. **绘图配置**:
   - **中文支持**:必须配置 `plt.rcParams['font.sans-serif'] = ['SimHei']` 和 `plt.rcParams['axes.unicode_minus'] = False` 以正确显示中文和负号。
   - **动态轴逻辑**:
     - 如果输入字典仅包含1个元素:创建单轴图表。
     - 如果输入字典包含2个元素:创建双轴图表 (`twinx`),左右轴颜色区分。
     - 如果是DataFrame分组:每组绘制一条线。
   - **样式**:设置标题、坐标轴标签、图例。X轴标签旋转45度以防重叠。建议图表大小 `figsize=(12, 8)`。
4. **输出方式**:
   - **严禁**调用 `plt.show()`。
   - 必须使用 `plt.savefig(out_file, bbox_inches='tight')` 保存图片。
   - 路径处理:优先使用用户指定路径,若无则使用默认文件名(如 'plot.png'),避免硬编码绝对路径。

# Anti-Patterns
- 不要在屏幕上显示图表(`plt.show()`)。
- 不要忽略中文字体配置,否则中文将显示为方框。
- 不要直接对DataFrame切片赋值而不使用`.loc`或`.copy()`,以避免警告。
- 不要忽略Tensor数据类型,必须转换为NumPy数组。
- 不要在双轴模式下混淆左右轴的数据对应关系。

## Triggers

- python绘制多条时间序列曲线
- python画图x轴时间y轴多组数据
- 单轴双轴动态切换绘图
- pandas matplotlib 中文
- 保存图片到文件
- 多系列折线图

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.