Matplotlib棒グラフ

「グラフ」タブにグラフをレンダリングします。

エディターで試してみる

概要

このスクリプトは matplotlib を利用して、言語の人気を比較する 2D の美しい棒グラフをレンダリングします。

エッジのスパイン、図のサイズ、および 16 進数の色を動的にフォーマットします。

コードと実行の出力

これは、ブラウザ エンジン上での matplotlib レンダリングをインラインで示しています。

import matplotlib.pyplot as plt
import numpy as np

langs = ['Python', 'JavaScript', 'TypeScript', 'Rust', 'Go']
scores = [95, 88, 82, 78, 75]
colors = ['#0D9488', '#F59E0B', '#3B82F6', '#EF4444', '#8B5CF6']

fig, ax = plt.subplots(figsize=(8, 5))
bars = ax.bar(langs, scores, color=colors, edgecolor='none', width=0.6)
ax.set_title('Language Popularity Index 2025', fontsize=14, fontweight='bold', pad=15)
ax.set_ylabel('Score', fontsize=11)
ax.set_ylim(60, 100)
ax.spines[['top', 'right']].set_visible(False)
for bar, score in zip(bars, scores):
    ax.text(bar.get_x() + bar.get_width()/2, bar.get_height() + 0.5,
            str(score), ha='center', va='bottom', fontweight='bold')
plt.tight_layout()
plt.show()
端子出力
Rendered visualization in the Graphs tab...

段階的な実装

  • データの視覚化
  • 科学的分析
  • 統計レポート

よくある質問

グラフはどこに表示されますか?

PyRunは、matplotlib レンダリング エンドポイントを自動的にインターセプトし、専用の分離された Graphs DOM 要素にパイプします。

関連トピック