visualization_code
Generate visualization code for statistical analysis in R, Python, or Stata to create coefficient plots, marginal effects, residual plots, power curves, and forest plots.
Instructions
시각화 코드 생성 (ggplot2, matplotlib, Stata graphs)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chart_type | Yes | 차트 유형 | |
| language | Yes | 언어 | |
| customization | No | 커스터마이징 옵션 |
Implementation Reference
- src/tools/index.ts:1653-1675 (handler)The main handler function for the 'visualization_code' tool. It takes chart_type and language as input and returns appropriate visualization code templates for R, Stata, or Python based on predefined templates.function handleVisualizationCode(args: Record<string, unknown>) { const chartType = args.chart_type as string; const language = args.language as string; const templates: Record<string, Record<string, string>> = { coefficient_plot: { r: `library(ggplot2)\nmodelsummary::modelplot(model, coef_omit = "Intercept")`, stata: `coefplot, drop(_cons) xline(0)`, python: `import matplotlib.pyplot as plt\ncoefs = model.params[1:]\nerrs = model.bse[1:]\nplt.errorbar(coefs.index, coefs, yerr=1.96*errs, fmt='o')` }, forest_plot: { r: `library(metafor)\nforest(meta_result)`, stata: `metan effect se, forestplot`, python: `# Use forestplot package or matplotlib` } }; return { chart_type: chartType, language, code: templates[chartType]?.[language] || "# Visualization code template" }; }
- src/tools/index.ts:405-419 (schema)The tool definition including name, description, and inputSchema for parameter validation (chart_type, language, customization). This registers the tool schema in the tools array.name: "visualization_code", description: "시각화 코드 생성 (ggplot2, matplotlib, Stata graphs)", inputSchema: { type: "object", properties: { chart_type: { type: "string", enum: ["coefficient_plot", "marginal_effects", "residual_plot", "power_curve", "forest_plot"], description: "차트 유형" }, language: { type: "string", enum: ["r", "stata", "python"], description: "언어" }, customization: { type: "object", description: "커스터마이징 옵션" }, }, required: ["chart_type", "language"], },
- src/tools/index.ts:840-841 (registration)The switch case in handleToolCall that routes calls to the visualization_code tool to its handler function.case "visualization_code": return handleVisualizationCode(args);