/stacked-chart-visualization
处理包含百分比字符串的分类占比数据,通过补全缺失维度并生成堆叠柱状图,直观展示多维度构成随时间或分类的变化趋势。
$ npx -y skills add OpenSenseNova/SenseNova-Skills --skill stacked-chart-visualization --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/stacked-chart-visualization
Context preview
The summary Claude sees to decide when to auto-load this skill.
处理包含百分比字符串的分类占比数据,通过补全缺失维度并生成堆叠柱状图,直观展示多维度构成随时间或分类的变化趋势。
SKILL.md
stacked-chart-visualization.SKILL.mdname: stacked-chart-visualization
description: "处理包含百分比字符串的分类占比数据,通过补全缺失维度并生成堆叠柱状图,直观展示多维度构成随时间或分类的变化趋势。"
Stacked_Chart_Visualization
Step1 定义百分比转换函数并提取原始数据。通过正则表达式或字符串处理将百分比格式转换为可计算的浮点数。
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# 配置中文字体,确保图表标签正常显示
plt.rcParams['font.sans-serif'] = ['SimHei', 'DejaVu Sans']
plt.rcParams['axes.unicode_minus'] = False
def convert_percentage(val):
"""
将百分比字符串转换为浮点数。
处理逻辑:去除百分号并转换为 float,若已经是数值则直接返回。
"""
if isinstance(val, str):
return float(val.strip('%'))
return val
# 示例数据提取逻辑(实际应用中替换为从 DataFrame 提取)
time_labels = ['1月', '2月', '3月', '4月', '5月', '6月'] # 泛化时间轴
cat1_raw = ['23.21%', '22.98%', '24.31%', '24.53%', '23.84%', '24.80%']
cat2_raw = ['25.17%', '25.67%', '25.77%', '25.98%', '25.17%', '25.61%']
cat3_raw = ['28.12%', '28.37%', '26.58%', '25.83%', '26.49%', '25.17%']
cat1_ratios = [convert_percentage(x) for x in cat1_raw]
cat2_ratios = [convert_percentage(x) for x in cat2_raw]
cat3_ratios = [convert_percentage(x) for x in cat3_raw]Step2 构建结构化数据表,将清洗后的数值整合进 DataFrame 以便进行向量化计算。
# 构建包含时间维度和各分类占比的结构化数据表
df = pd.DataFrame({
'group_col': time_labels,
'cat_1': cat1_ratios,
'cat_2': cat2_ratios,
'cat_3': cat3_ratios
})Step3 计算缺失维度的占比。在已知部分维度占比的情况下,通过总和 100% 的约束推算剩余维度的数值,并进行数据校验。
# 计算已知维度的总占比
target_cols = ['cat_1', 'cat_2', 'cat_3']
df['current_total'] = df[target_cols].sum(axis=1)
# 推算剩余维度(如“其他”或特定分类)的占比
df['cat_remainder'] = 100 - df['current_total']
# 验证数据完整性:确保所有维度相加接近 100
df['final_check'] = df[target_cols + ['cat_remainder']].sum(axis=1)
Step4 使用堆叠柱状图进行可视化。核心在于利用 `bottom` 参数逐层累加高度,并优化图表美学配置。
# 设置绘图风格与画布
plt.figure(figsize=(12, 6), dpi=100)
sns.set_style('whitegrid')
# 核心堆叠逻辑:每一层的 bottom 是前几层高度的总和
plt.bar(df['group_col'], df['cat_1'], label='分类1', color='#5DADE2')
plt.bar(df['group_col'], df['cat_2'], bottom=df['cat_1'], label='分类2', color='#58D68D')
plt.bar(df['group_col'], df['cat_3'], bottom=df['cat_1'] + df['cat_2'], label='分类3', color='#EC7063')
plt.bar(df['group_col'], df['cat_remainder'], bottom=df['cat_1'] + df['cat_2'] + df['cat_3'], label='其他', color='#F4D03F')
# 图表辅助元素优化
plt.xlabel('统计周期')
plt.ylabel('占比 (%)')
plt.title('多维度占比变化趋势分析')
plt.legend(loc='upper right', bbox_to_anchor=(1.1, 1))
plt.xticks(rotation=45) # 避免标签重叠
plt.tight_layout()Step5 导出分析结果。将生成的图表保存为高分辨率图片,并清理内存。
# 保存图表,设置 dpi 确保清晰度,bbox_inches 确保标签不被截断
output_path = 'stacked_ratio_analysis.png'
plt.savefig(output_path, dpi=300, bbox_inches='tight')
plt.show()
plt.close()
Read more
name: stacked-chart-visualization description: "处理包含百分比字符串的分类占比数据,通过补全缺失维度并生成堆叠柱状图,直观展示多维度构成随时间或分类的变化趋势。"
Stacked_Chart_Visualization
Step1 定义百分比转换函数并提取原始数据。通过正则表达式或字符串处理将百分比格式转换为可计算的浮点数。
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# 配置中文字体,确保图表标签正常显示
plt.rcParams['font.sans-serif'] = ['SimHei', 'DejaVu Sans']
plt.rcParams['axes.unicode_minus'] = False
def convert_percentage(val):
"""
将百分比字符串转换为浮点数。
处理逻辑:去除百分号并转换为 float,若已经是数值则直接返回。
"""
if isinstance(val, str):
return float(val.strip('%'))
return val
# 示例数据提取逻辑(实际应用中替换为从 DataFrame 提取)
time_labels = ['1月', '2月', '3月', '4月', '5月', '6月'] # 泛化时间轴
cat1_raw = ['23.21%', '22.98%', '24.31%', '24.53%', '23.84%', '24.80%']
cat2_raw = ['25.17%', '25.67%', '25.77%', '25.98%', '25.17%', '25.61%']
cat3_raw = ['28.12%', '28.37%', '26.58%', '25.83%', '26.49%', '25.17%']
cat1_ratios = [convert_percentage(x) for x in cat1_raw]
cat2_ratios = [convert_percentage(x) for x in cat2_raw]
cat3_ratios = [convert_percentage(x) for x in cat3_raw]Step2 构建结构化数据表,将清洗后的数值整合进 DataFrame 以便进行向量化计算。
# 构建包含时间维度和各分类占比的结构化数据表
df = pd.DataFrame({
'group_col': time_labels,
'cat_1': cat1_ratios,
'cat_2': cat2_ratios,
'cat_3': cat3_ratios
})Step3 计算缺失维度的占比。在已知部分维度占比的情况下,通过总和 100% 的约束推算剩余维度的数值,并进行数据校验。
# 计算已知维度的总占比 target_cols = ['cat_1', 'cat_2', 'cat_3'] df['current_total'] = df[target_cols].sum(axis=1) # 推算剩余维度(如“其他”或特定分类)的占比 df['cat_remainder'] = 100 - df['current_total'] # 验证数据完整性:确保所有维度相加接近 100 df['final_check'] = df[target_cols + ['cat_remainder']].sum(axis=1)
Step4 使用堆叠柱状图进行可视化。核心在于利用 `bottom` 参数逐层累加高度,并优化图表美学配置。
# 设置绘图风格与画布
plt.figure(figsize=(12, 6), dpi=100)
sns.set_style('whitegrid')
# 核心堆叠逻辑:每一层的 bottom 是前几层高度的总和
plt.bar(df['group_col'], df['cat_1'], label='分类1', color='#5DADE2')
plt.bar(df['group_col'], df['cat_2'], bottom=df['cat_1'], label='分类2', color='#58D68D')
plt.bar(df['group_col'], df['cat_3'], bottom=df['cat_1'] + df['cat_2'], label='分类3', color='#EC7063')
plt.bar(df['group_col'], df['cat_remainder'], bottom=df['cat_1'] + df['cat_2'] + df['cat_3'], label='其他', color='#F4D03F')
# 图表辅助元素优化
plt.xlabel('统计周期')
plt.ylabel('占比 (%)')
plt.title('多维度占比变化趋势分析')
plt.legend(loc='upper right', bbox_to_anchor=(1.1, 1))
plt.xticks(rotation=45) # 避免标签重叠
plt.tight_layout()Step5 导出分析结果。将生成的图表保存为高分辨率图片,并清理内存。
# 保存图表,设置 dpi 确保清晰度,bbox_inches 确保标签不被截断 output_path = 'stacked_ratio_analysis.png' plt.savefig(output_path, dpi=300, bbox_inches='tight') plt.show() plt.close()
The SenseNova model family plugs directly into agent runtimes such as OpenClaw and hermes-agent, with the skills in this repository extending the models with concrete, end-to-end office capabilities.
Repo: OpenSenseNova/SenseNova-Skills
Other skills on sensenova-skills.
- /sn-da-excel-workflow
Excel 数据分析多步编排器。覆盖:(1) 读取多 Sheet Excel 文件并统计行数,(2) 大文件检测(≥10k 行自动 Parquet 优化),(3) 数据清洗(缺失值、文本标准化、无效字符),(4) 条件筛选与分类提取,(5) 跨 Sheet 统计聚合,(6) 导出 Excel/CSV 并提供下载链接。覆盖从数据读取到报告生成全流程,按步骤编排 capability 子 skill。**遇到以下任一情况就主动使用本 skill,不要自行写几行 pandas 就回答**:①用户出现触发词:Excel 分析 / 表格分析 / 数据分析 /
Open skill - /category-coloring
当Excel文件总行数超过1万行时,通过转换为Parquet格式提升读取性能,提取目标指标并计算最大值,最后将结果输出为Excel并对特定行进行高亮标注。
Open skill - /duplicate-value-coloring
对比Excel多表中的特定系数并对异常值进行颜色标记。
Open skill - /outlier-coloring
识别 Excel 中的超限数值与错误单元格并进行高亮标注。
Open skill - /threshold-cell-coloring
根据Excel总行数自动切换Parquet加速读取,计算特定维度的时间序列平均值,并使用openpyxl输出带有条件格式(如低于均值标绿)和自定义样式的分析报告。
Open skill - /top-value-coloring
根据数据规模动态选择处理策略,对多表数据进行合并、统计筛选,并利用 openpyxl 实现关键指标的自动化样式高亮与格式化导出。
Open skill

