用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/brycewang-stanford/Auto-Empirical-Research-Skills --skill d3-visualization-guide命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
Route empirical-research requests through the Auto-Empirical Research Skills catalog when this whole repository is installed as one skill in Codex, CodeBuddy, Claude Code, or another IDE. Use to choose and load the right vendored AERS skill for causal inference, econometrics, replication, data acquisition, manuscript writing, peer review and referee responses, citation checking, de-AIGC editing, or full empirical-paper workflows without reading the entire repository at once.
中英双语学术降 AIGC / bilingual academic de-AIGC skill. Removes AI-generated writing signatures from empirical papers in economics, management, and the social sciences — in both English and Chinese. Covers Turnitin AI, GPTZero, Originality.ai on the English side and 知网 AMLC, 万方, 维普 on the Chinese side. Uses a six-step loop (intake → audit → claim-evidence check → differentiated rewrite → five-dimension self-score → cold-reader recheck) with two pattern libraries (22 English + 17 Chinese patterns), section-by-section strategies for empirical papers, and hard protections that keep every number, coefficient, and citation intact.
Use when a research task needs reproducible Kaggle discovery, metadata inspection, bounded public-data downloads, competition or kernel discovery, model discovery, or an explicitly approved Kaggle write/delete operation through the official CLI.
基于 SOC 职业分类
| name | d3-visualization-guide |
| description | Guide to D3.js for building custom interactive data visualizations |
| metadata | {"openclaw":{"emoji":"📊","category":"analysis","subcategory":"dataviz","keywords":["data visualization","D3.js","interactive charts","SVG","web visualization","scientific plots"],"source":"https://github.com/d3/d3"}} |
D3.js (Data-Driven Documents) is the most powerful and flexible JavaScript library for producing dynamic, interactive data visualizations in web browsers. With over 112K stars on GitHub, D3 has become the de facto standard for custom data visualization on the web. It uses HTML, SVG, and CSS to bring data to life, giving researchers full control over the final visual output.
Unlike higher-level charting libraries, D3 operates at the level of individual SVG elements and data bindings, which means researchers can create entirely bespoke visualizations tailored to their specific datasets and publication requirements. This makes it particularly valuable for academic work where standard chart types may not adequately represent complex research findings.
D3 provides a comprehensive ecosystem of modules covering everything from scales and axes to geographic projections, force-directed layouts, and hierarchical data structures. The library follows a functional, composable design that allows researchers to combine modules as needed for their specific visualization tasks.
D3 revolves around the concept of binding data to DOM elements and applying data-driven transformations. The key patterns every researcher should understand are selections, data joins, scales, and axes.
// Load research data from CSV
const data = await d3.csv("experiment_results.csv", d => ({
condition: d.condition,
measurement: +d.measurement,
error: +d.standard_error
}));
// Create an SVG container
const svg = d3.select("#chart")
.append("svg")
.attr("width", 800)
.attr("height", 500);
// Binddata to elements using the enter-update-exit pattern
svg.selectAll("circle")
.data(data)
.join("circle")
.attr("cx", d => xScale(d.condition))
.attr("cy", d => yScale(d.measurement))
.attr("r", 5)
.attr("fill", "#3B82F6");
// Linear scale for continuous measurements
const yScale = d3.scaleLinear()
.domain([0, d3.max(data, d => d.measurement)])
.range([height - margin.bottom, margin.top]);
// Band scale for categorical conditions
const xScale = d3.scaleBand()
.domain(data.map(d => d.condition))
.range([margin.left, width - margin.right])
.padding(0.3);
// Add axes with proper formatting
svg.append("g")
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(xScale));
svg.append("g")
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(yScale).tickFormat(d3.format(".2f")));
function createErrorBarPlot(data, container) {
const margin = { top: 40, right: 30, bottom: 60, left: 70 };
const width = 700 - margin.left - margin.right;
const height = 450 - margin.top - margin.bottom;
const svg = d3.select(container)
.append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", `translate(${margin.left},${margin.top})`);
const x = d3.scaleBand()
.domain(data.map(d => d.group))
.range([0, width])
.padding(0.4);
const y = d3.scaleLinear()
.([, d3.(data, d. + d.) * ])
.([height, ]);
svg.()
.(data)
.()
.(, )
.(, (d.))
.(, (d.))
.(, x.())
.(, height - (d.))
.(, d3.[i]);
svg.()
.(data)
.()
.(, (d.) + x.() / )
.(, (d.) + x.() / )
.(, (d. - d.))
.(, (d. + d.))
.(, )
.(, );
capWidth = ;
[, ].( {
svg.()
.(data)
.()
.(, (d.) + x.() / - capWidth)
.(, (d.) + x.() / + capWidth)
.(, (d. + (pos === ? d. : -d.)))
.(, (d. + (pos === ? d. : -d.)))
.(, )
.(, );
});
svg.()
.(, )
.(d3.(x))
.()
.(, );
svg.()
.(d3.(y))
.()
.(, );
}
function createCorrelationHeatmap(matrix, labels, container) {
const size = 500;
const cellSize = size / labels.length;
const colorScale = d3.scaleSequential(d3.interpolateRdBu)
.domain([1, -1]);
const svg = d3.select(container)
.append("svg")
.attr("width", size + 120)
.attr("height", size + 120);
const g = svg.append("g")
.attr("transform", "translate(100, 20)");
// Draw cells
labels.forEach((rowLabel, i) => {
labels.forEach((colLabel, j) => {
g.append("rect")
.attr("x", j * cellSize)
.attr("y", i * cellSize)
.attr("width", cellSize - 1)
.attr("height", cellSize - 1)
.attr("fill", (matrix[i][j]))
.()
.();
g.()
.(, j * cellSize + cellSize / )
.(, i * cellSize + cellSize / )
.(, )
.(, )
.(, )
.(matrix[i][j].());
});
});
g.()
.(labels)
.()
.(, -)
.(, i * cellSize + cellSize / )
.(, )
.(, )
.(, )
.( d);
}
D3 excels at adding interactivity to visualizations, which is valuable for research presentations, supplementary materials, and data exploration during analysis.
// Create a tooltip div
const tooltip = d3.select("body").append("div")
.attr("class", "tooltip")
.style("position", "absolute")
.style("background", "rgba(0,0,0,0.8)")
.style("color", "#fff")
.style("padding", "8px 12px")
.style("border-radius", "4px")
.style("font-size", "12px")
.style("pointer-events", "none")
.style("opacity", 0);
// Attach to data points
svg.selectAll("circle")
.on("mouseover", (event, d) => {
tooltip.transition().duration(200).style("opacity", 1);
tooltip.html(
`<strong>${d.sample_id}</strong><br/>` +
`Value: ${d.measurement.toFixed()}<br/>` +
)
.(, (event. + ) + )
.(, (event. - ) + );
})
.(, {
tooltip.().().(, );
});
const zoom = d3.zoom()
.scaleExtent([1, 20])
.on("zoom", (event) => {
chartGroup.attr("transform", event.transform);
});
svg.call(zoom);
When preparing figures for journal submissions, D3 SVG output can be exported directly to vector formats.
// Extract SVG markup for saving
function exportSVG(svgElement) {
const serializer = new XMLSerializer();
const svgString = serializer.serializeToString(svgElement);
const blob = new Blob([svgString], { type: "image/svg+xml" });
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "figure.svg";
link.click();
URL.revokeObjectURL(url);
}
Researchers can then convert SVG to PDF or EPS using tools like Inkscape or cairosvg for submission to journals that require specific formats.