본문으로 건너뛰기
cccskills
무료GitHub에 공개

visualization

Use this when creating, modifying, reviewing, or saving charts, figures, plots, or visual summaries — including matplotlib/seaborn code, EDA figures, report figures, dashboards, or any task involving Japanese chart labels, color palettes, or figure styling.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md5.7 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Skill: Visualization

Use this skill whenever the user asks to:

  • Plot, visualize, chart, or graph data.
  • Create figures for EDA, reports, dashboards, or presentations.
  • Modify or improve existing matplotlib / seaborn code.
  • Save figures to disk for reports or notebooks.

Library

  • Use matplotlib for charts.
  • Use seaborn alongside matplotlib for theming, palettes, and statistical plots.

Global Setup (do this first)

At the start of any notebook or script that produces figures, set the theme once. font_scale enlarges all text elements proportionally, so individual fontsize= arguments are usually unnecessary.

import matplotlib.pyplot as plt
import seaborn as sns

sns.set_theme(
    style="whitegrid",
    palette="muted",
    font_scale=1.2,
)

Japanese text

If any text (titles, labels, legends, annotations) contains Japanese, configure a CJK-capable font, otherwise characters render as tofu (□□□).

Preferred approach (cross-platform):

import japanize_matplotlib  # uv add japanize-matplotlib

Alternative (set an installed CJK font explicitly):

plt.rcParams["font.family"] = "Noto Sans CJK JP"  # or "IPAexGothic", "Hiragino Sans", "Yu Gothic"

Figure Creation

  • Do not use the stateful plt.figure(...) / plt.plot(...) style.
  • Always create figures and axes explicitly, and prefer constrained_layout=True over tight_layout():
fig, ax = plt.subplots(figsize=(10, 6), constrained_layout=True)
  • Use the object-oriented API: ax.set_title(), ax.set_xlabel(), ax.plot(), etc.
  • figsize=(10, 6) is a reasonable default. Adjust to content: wide time series → (12, 4), square scatter → (6, 6), multi-panel → scale up accordingly.

Color Map / Color Palette

Choose by data type:

  • Categorical: "muted", "Set2", "colorblind" (seaborn palettes).
  • Sequential (continuous): "viridis", "cividis", "mako" — perceptually uniform.
  • Diverging: "coolwarm", "RdBu", "vlag".
  • Forbidden: "jet", "rainbow" — not perceptually uniform, poor for colorblind viewers.

Font Size

sns.set_theme(font_scale=1.2) covers most cases. Override per-element only when needed (e.g. a long title needs to be smaller, or one label needs emphasis):

ax.set_title("...", fontsize=18)

Do not repeat fontsize= on every call — it is redundant when font_scale is set.

Axis Scale Guidelines

  • Bar charts: start y-axis at 0 (ax.set_ylim(bottom=0)). Truncated bars are misleading.
  • Line / scatter: do not force y-axis to 0 — it can hide meaningful variation. Let matplotlib autoscale, or set limits based on the data range.
  • Log scale: use ax.set_yscale("log") when data spans multiple orders of magnitude.

Legend

  • Use ax.legend() only when ≥2 series are plotted.
  • If the auto-placement overlaps data, set explicitly: ax.legend(loc="upper left") or place outside: ax.legend(loc="center left", bbox_to_anchor=(1.0, 0.5)).

Saving

  • Save final figures under outputs/figures/.
  • Diagnostic figures produced by a *-diagnostics skill go under outputs/diagnostics/<YYYYMMDD-HHMM>_<skill>/ instead (gitignored; the report links the directory and shows only the 判定表).
  • Use the path utilities from src/analysis_project/paths.py.
from analysis_project.paths import outputs_dir, ensure_parent_dir

# 出力パスを構成して保存
output_path = outputs_dir() / "figures" / "survival_by_class.png"
ensure_parent_dir(output_path)
fig.savefig(output_path, dpi=150)
  • Use descriptive snake_case filenames: monthly_sales_2024h1.png, not fig1.png.
  • DPI guidance:
    • Notebook / README / slides: dpi=150
    • Publication / print: dpi=300
  • Always call plt.close(fig) after saving to free memory.
fig.savefig("outputs/figures/monthly_sales.png", dpi=150, bbox_inches="tight")
plt.close(fig)

Chart Quality Checklist

Before finalizing a chart, verify:

  • Title clearly describes what the chart shows.
  • Axis labels include units where applicable (e.g. "売上 (万円)", "Latency (ms)").
  • Font sizes are readable (rely on font_scale=1.2 as baseline).
  • Color palette is perceptually uniform / colorblind-friendly (no jet/rainbow).
  • Date range noted in title, subtitle, or annotation when relevant.
  • Sample / filter note when data is subsetted (e.g. "n=1,234, 2024年1月〜6月").
  • Bar charts start y-axis at 0; other chart types use sensible limits.
  • Legend present when multiple series; placement does not overlap data.
  • Japanese text renders correctly (japanize-matplotlib or CJK font configured).
  • Saved to outputs/figures/ with descriptive filename, followed by plt.close(fig).

Example

from pathlib import Path
import matplotlib.pyplot as plt
import seaborn as sns
import japanize_matplotlib  # noqa: F401  # 日本語フォント有効化

sns.set_theme(style="whitegrid", palette="muted", font_scale=1.2)

Path("outputs/figures").mkdir(parents=True, exist_ok=True)

fig, ax = plt.subplots(figsize=(10, 6), constrained_layout=True)

ax.bar(categories, values)
ax.set_title("月別売上推移 (2024年1月〜6月)")
ax.set_xlabel("月")
ax.set_ylabel("売上 (万円)")
ax.set_ylim(bottom=0)  # 棒グラフは0起点

fig.savefig("outputs/figures/monthly_sales_2024h1.png", dpi=150, bbox_inches="tight")
plt.close(fig)

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use this when summarizing analysis results, writing reports, documenting experiment outcomes, or presenting model evaluation — including structuring findings in Japanese with conclusions, facts, assumptions, interpretations, and caveats.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

atsushi-green/ds-ai-coding-skills912026년 10월 4일 업데이트

因果推論・効果検証(A/B テスト / ABテスト / オンライン実験 / リフト / SRM / CUPED、観察データの処置効果 / ATE / ATT / CATE / 傾向スコア / propensity score / IPW / 二重頑健 / DML / causal forest、準実験 / 差の差 / DiD / イベントスタディ / 操作変数 / IV / 2SLS / 回帰不連続 / RDD / 合成コントロール)を実行したら必ずセットで出す図と値のルーター。 proportions_ztest, chisquare, statsmodels.stats.power, dowhy, econml, causalml, doubleml, propensity, LinearDML, IV2SLS, rdrobust, rddensity, pysyncon, treat*post がコードに現れたとき、またはユーザーが「ABテストの結果を 見て」「施策の効果を推定して」「差の差で」「傾向スコアで揃えて」「閾値前後で比較して」と言ったときに使う。SRM・ バランス・並行トレンド・first-stage に言及がなくても適用する。SKILL.md のルーティング表で設計を特定し、対応する references/<設計>.md を読んでから実行する。実験でない群間比較の検定は statistical-inference-diagnostics、 予測モデルの解釈(SHAP 等)は predictive-modeling-diagnostics を使う。

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

atsushi-green/ds-ai-coding-skills912026년 10월 4일 업데이트

Use this when performing DataFrame operations — including loading, filtering, joining, aggregating, transforming, or reshaping tabular data with polars or pandas.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

atsushi-green/ds-ai-coding-skills912026년 10월 4일 업데이트

Use this when creating, editing, executing, or reviewing Jupyter notebooks — including cell structure, kernel management, extracting reusable logic to src/, and ensuring notebooks are restartable.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

atsushi-green/ds-ai-coding-skills912026년 10월 4일 업데이트

Use this when reading from or writing to local files — including constructing file paths with pathlib, creating directories, choosing output locations, and using path utilities from src/analysis_project/paths.py.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

atsushi-green/ds-ai-coding-skills912026년 10월 4일 업데이트

分析を始める前に構造化された分析計画を作成する

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

atsushi-green/ds-ai-coding-skills912026년 10월 4일 업데이트

atsushi-green의 스킬 모두 보기

이 스킬의 문제 신고