agentsclimarketplace

Python plotting chinese twinx pandas

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8_GLM4.7/python_plotting_chinese_twinx_pandas

AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill python_plotting_chinese_twinx_pandas

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

What its author says it does

Copied from the file, not written here

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.

SKILL.md

3.3 KB, as published. Nobody here has run it

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 中文
  • 保存图片到文件
  • 多系列折线图

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.