graphing

작성자: anthropic

표 형식 데이터에서 차트킷 기본 요소를 사용하여 정제된 차트(시계열, 막대, 선, 영역, 원형, 산점도 또는 데이터에 적합한 기타 모든 유형)를 구성합니다.

npx skills add https://github.com/anthropics/claude-tag-plugins --skill graphing

Graphing

You write the plotting code. The kit provides the parts that should stay consistent across every chart: typography, color derivation from the background, the title and caption frame, and offline HTML packaging. Everything about the chart itself is your judgement applied to the data in front of you.

The primitives

Import chartkit by putting this skill's scripts/ directory on sys.path. Use its absolute path, not a relative path, since your working directory is the user's project. The examples below write it as /path/to/graphing/scripts; substitute the real path.

Relevant primitives:

  • theme(bg, font): sets matplotlib rcParams and returns resolved colors. Foreground colors derive from background luminance, so a dark bg produces a correct dark chart. Fields: bg dark text muted grid spine accent secondary series font_css.
  • palette(n, base): n colors. No base cycles the default series, a hex base builds a ramp from it, a list cycles the list.
  • finish(ax, title, subtitle, source): The typographic frame. Left-aligned bold title, muted subtitle, small provenance caption.
  • save(fig, stem, formats, dpi): Writes stem.png, stem.svg, or both. Returns the paths.
  • write_html(out, data, component_js, title, bg, font): Self-contained interactive page. Inlines React, ReactDOM, react-is, and Recharts from third_party/ so the file opens offline. Your component reads window.__CHART_DATA__ and renders into #root.
  • zero_fill_days(pairs) rolling_mean(values, w) log_floor(values): Small data helpers for the gotchas listed below. Use them only when they fit.

Steps

  1. Look at the data and decide what it deserves. Shape, count, and meaning drive the choice: trends over time want lines or day bars, ranked categories want horizontal bars, parts of a whole with few slices can be a pie, correlation wants a scatter. Nothing limits you to those: stacked areas, dual axes, small multiples, annotated thresholds are all just code you write.

  2. Infer colors from context. Check your conversation and memory for design indicators: a tailwind config, CSS variables, or brand guidelines, and consider the semantic meaning of the data (red or amber for errors, green for success). Pass the destination background to theme(bg=...) and brand colors to palette(base=...) or directly. Fall back to the defaults only when nothing is inferable. The font defaults to Inter and only changes when the user names a typeface or the destination has a documented brand font.

  3. Write a short script in your scratchpad that imports chartkit, builds the figure with plain matplotlib (or a Recharts component for interactive output), calls finish, and saves.

  4. Render and look at the result. Read the PNG back and check it with your own eyes before handing it over: labels legible, nothing overlapping, colors distinguishable, the story of the data actually visible. Fix and re-render until it is right.

The shape of a chart script

PNG or SVG via matplotlib:

import sys
sys.path.insert(0, "/path/to/graphing/scripts")
import chartkit as ck
import matplotlib.pyplot as plt

c = ck.theme()                       # or theme(bg="#0f1419") for a dark surface
fig, ax = plt.subplots(figsize=(10, 5))
# ...plain matplotlib against the data, using c.accent, c.secondary, ck.palette(...)
ck.finish(ax, title="What the chart shows", subtitle="scope or time range",
          source="source: where the data came from, date")
print(ck.save(fig, "out/report", formats=("png", "svg")))

Interactive HTML via Recharts, written as plain React.createElement with no JSX and no build step:

component = """
(function () {
  var e = React.createElement
  var R = window.Recharts
  var DATA = window.__CHART_DATA__
  function App() {
    return e(R.ResponsiveContainer, { width: "100%", height: 420 },
      e(R.LineChart, { data: DATA },
        e(R.CartesianGrid, { stroke: "GRID", vertical: false }),
        e(R.XAxis, { dataKey: "x" }), e(R.YAxis, null),
        e(R.Tooltip, null),
        e(R.Line, { dataKey: "y", stroke: "ACCENT", strokeWidth: 2.4,
                    dot: false, isAnimationActive: false })))
  }
  ReactDOM.createRoot(document.getElementById("root")).render(e(App))
})()
"""
ck.write_html("out/report.html", data, component, title="What the chart shows")

Substitute real colors from the theme into the component and keep isAnimationActive: false so the chart is complete the moment the file opens.

Judgement, not flags

These are the defaults of good charts. Deviate when the data argues for it.

  • Rotate x labels only when they would otherwise collide. Short labels stay horizontal.
  • Cap bar width when there are few categories. Two bars should not fill the canvas edge to edge.
  • Label bars with their values when there are roughly a dozen or fewer. Axes and gridlines are for reading trends, not exact values.
  • Rank categorical bars by value unless the categories have a natural order.
  • Long category names read better on a horizontal bar chart.
  • A title states what the chart shows. A subtitle carries the time range or scope. The source caption says where the data came from and when. Skip any of them only deliberately.
  • Legends only when there is more than one series. A single series is named by the title.
  • Annotate the chart with what matters: a deploy line, a threshold, the peak, the anomaly the user asked about. An annotation the reader did not need is clutter.

Gotchas the helpers exist for

  • Calendar gaps: a timeseries with missing days misleads on a continuous axis. zero_fill_days fills them with zero. Skip it when zeros would be the lie (sparse sampling rather than absence of events).
  • Rolling averages: rolling_mean is trailing, early points average what exists so far. Do not center it on data that ends today.
  • Log scales: bars whose value equals the axis minimum get zero height. log_floor gives a lower bound one decade down.
  • Negative values: matplotlib handles them, but check the y limits include them and add a zero line when bars go both ways. Recharts y domains default to starting at zero, so pass an explicit domain on the YAxis when data is negative or log scaled.

Verification

Run a minimal render and look at it.

python3 -c "
import sys
sys.path.insert(0, '/path/to/graphing/scripts')
import chartkit as ck
import matplotlib.pyplot as plt
c = ck.theme()
fig, ax = plt.subplots(figsize=(8, 4))
ax.bar(['A', 'B', 'C'], [10, 30, 20], color=c.accent, width=0.5)
ck.finish(ax, title='chartkit smoke test')
print(ck.save(fig, '/tmp/ck_smoke'))
"

Confirm a non-empty PNG is written, then read it back and check it renders correctly.

anthropic의 다른 스킬

analyzing-financial-statements
anthropic
이 스킬은 재무제표 데이터로부터 투자 분석을 위한 주요 재무 비율과 지표를 계산합니다.
applying-brand-guidelines
anthropic
이 스킬은 생성된 모든 문서에 일관된 기업 브랜딩과 스타일(색상, 글꼴, 레이아웃, 메시징 포함)을 적용합니다.
creating-financial-models
anthropic
이 스킬은 DCF 분석, 민감도 테스트, 몬테카를로 시뮬레이션, 시나리오 플래닝을 포함한 고급 재무 모델링 제품군을 투자…에 제공합니다.
board-minutes
anthropic
이사회 또는 위원회 회의록을 사내 형식으로 작성합니다. 캘린더에서 예정된 이사회 및 위원회 회의를 자동으로 감지하고, 안건을 요청한 후…
crm-cleanup
anthropic
HubSpot에서 오래된 거래, 중복 연락처, 누락된 필드를 스캔한 후 소유자가 승인한 항목을 수정합니다. 선택적 범위 인수를 받아 거래, 연락처 등을 지정할 수 있습니다.
redshift-api
anthropic
Amazon Redshift에 대해 SQL 실행 — 명령문 제출, 상태 폴링, 결과 페이지 탐색, 데이터베이스/스키마/테이블 탐색. 사용자가 원할 때마다 이 기능을 사용하세요…
ticket-deflector
anthropic
고객이 전달한 이메일이나 티켓을 읽고, PayPal에서 주문/환불 상태를 가져오며, HubSpot에서 계정 내역을 조회한 후, 소유자의 어조에 맞춰 답변을 작성합니다.
reg-feed-watcher
anthropic
규제 피드를 지금 확인하고, 마지막 확인 이후 새로 추가된 내용을 사용자의 중요도 기준에 따라 필터링하여 보고합니다. 사용자가 "피드 확인해 줘"라고 말할 때 사용하세요.