Pythonを使って出版品質の可視化グラフを作成します。 次のような場合に使用: - クエリ結果やデータフレーム(表形式データ)をグラフに変換したい - トレンド(時系列の変化)や比較に適したグラフタイプを選びたい - レポートやプレゼンテーション用の図表を生成したい - マウスオーバーやズーム機能を備えた対話的なグラフが必要
Create publication-quality visualizations with Python. Use when turning query results or a DataFrame into a chart, selecting the right chart type for a trend or comparison, generating a plot for a report or presentation, or needing an interactive chart with hover and zoom.
見慣れないプレースホルダーが表示される場合や、接続されているツールを確認したい場合は、CONNECTORS.md を参照してください。
Pythonを使用して、出版品質のデータビジュアライゼーションを作成します。 明確さ・正確さ・デザインのベストプラクティスに従い、データからチャートを生成します。
/create-viz <データソース> [チャートの種類] [追加の指示]
以下の項目を確認します:
データウェアハウスが接続済みで、クエリが必要な場合:
データが貼り付けまたはアップロードされた場合:
会話内の過去の分析からのデータの場合:
ユーザーがチャートの種類を指定していない場合は、データと目的に基づいて推奨します:
| データの関係性 | 推奨チャート |
|---|---|
| 時系列のトレンド | 折れ線グラフ |
| カテゴリ間の比較 | 棒グラフ(カテゴリが多い場合は横棒グラフ) |
| 全体に対する構成比 | 積み上げ棒グラフまたは面グラフ(6カテゴリ未満の場合を除き、円グラフは避ける) |
| 値の分布 | ヒストグラムまたは箱ひげ図 |
| 2変数間の相関 | 散布図 |
| 2変数の時系列比較 | 二軸折れ線グラフまたはグループ棒グラフ |
| 地理データ | コロプレスマップ |
| ランキング | 横棒グラフ |
| フローまたはプロセス | サンキーダイアグラム |
| 関係性のマトリクス | ヒートマップ |
ユーザーが指定していない場合は、推奨理由を簡潔に説明します。
目的に応じて、以下のいずれかのライブラリを使用したPythonコードを作成します:
コードの要件:
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
# プロフェッショナルなスタイルを設定
plt.style.use('seaborn-v0_8-whitegrid')
sns.set_palette("husl")
# 適切なサイズでfigureを作成
fig, ax = plt.subplots(figsize=(10, 6))
# [チャート固有のコード]
# 以下は必ず含める:
ax.set_title('明確でわかりやすいタイトル', fontsize=14, fontweight='bold')
ax.set_xlabel('X軸ラベル', fontsize=11)
ax.set_ylabel('Y軸ラベル', fontsize=11)
# 数値を適切にフォーマット
# - パーセント: '0.452' ではなく '45.2%'
# - 通貨: '1200000' ではなく '$1.2M'
# - 大きな数値: '2300' や '1500000' ではなく '2.3K' や '1.5M'
# 不要な装飾を除去
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
plt.tight_layout()
plt.savefig('chart_name.png', dpi=150, bbox_inches='tight')
plt.show()
カラー:
タイポグラフィ:
レイアウト:
正確性:
/create-viz 直近12ヶ月の月別収益を、トレンドを強調した折れ線グラフで表示してください
/create-viz こちらが製品別NPSデータです: [データを貼り付け]。製品をスコア順にランキングした横棒グラフを作成してください。
/create-viz ordersテーブルをクエリして、曜日と時間帯別の注文数をヒートマップで表示してください
If you see unfamiliar placeholders or need to check which tools are connected, see CONNECTORS.md.
Create publication-quality data visualizations using Python. Generates charts from data with best practices for clarity, accuracy, and design.
/create-viz <data source> [chart type] [additional instructions]
Determine:
If data warehouse is connected and data needs querying:
If data is pasted or uploaded:
If data is from a previous analysis in the conversation:
If the user didn't specify a chart type, recommend one based on the data and question:
| Data Relationship | Recommended Chart |
|---|---|
| Trend over time | Line chart |
| Comparison across categories | Bar chart (horizontal if many categories) |
| Part-to-whole composition | Stacked bar or area chart (avoid pie charts unless <6 categories) |
| Distribution of values | Histogram or box plot |
| Correlation between two variables | Scatter plot |
| Two-variable comparison over time | Dual-axis line or grouped bar |
| Geographic data | Choropleth map |
| Ranking | Horizontal bar chart |
| Flow or process | Sankey diagram |
| Matrix of relationships | Heatmap |
Explain the recommendation briefly if the user didn't specify.
Write Python code using one of these libraries based on the need:
Code requirements:
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
# Set professional style
plt.style.use('seaborn-v0_8-whitegrid')
sns.set_palette("husl")
# Create figure with appropriate size
fig, ax = plt.subplots(figsize=(10, 6))
# [chart-specific code]
# Always include:
ax.set_title('Clear, Descriptive Title', fontsize=14, fontweight='bold')
ax.set_xlabel('X-Axis Label', fontsize=11)
ax.set_ylabel('Y-Axis Label', fontsize=11)
# Format numbers appropriately
# - Percentages: '45.2%' not '0.452'
# - Currency: '$1.2M' not '1200000'
# - Large numbers: '2.3K' or '1.5M' not '2300' or '1500000'
# Remove chart junk
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
plt.tight_layout()
plt.savefig('chart_name.png', dpi=150, bbox_inches='tight')
plt.show()
Color:
Typography:
Layout:
Accuracy:
/create-viz Show monthly revenue for the last 12 months as a line chart with the trend highlighted
/create-viz Here's our NPS data by product: [pastes data]. Create a horizontal bar chart ranking products by score.
/create-viz Query the orders table and create a heatmap of order volume by day-of-week and hour
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。