MatplotlibBagan Batang
Merender bagan di tab GRAFIK.
Ikhtisar
Skrip ini menggunakan matplotlib untuk membuat diagram batang estetika 2D yang membandingkan popularitas bahasa.
Ini secara dinamis memformat duri tepi, ukuran gambar, dan warna hex.
Kode & Output Eksekusi
Ini menunjukkan rendering matplotlib melalui inline mesin browser.
chart.py
Coba di Editorimport 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()Keluaran Terminal
Rendered visualization in the Graphs tab...Implementasi Langkah demi Langkah
- Visualisasi data
- Analisis ilmiah
- Pelaporan statistik
Pertanyaan yang Sering Diajukan
Dimana grafiknya muncul?
PyRunsecara otomatis mencegat titik akhir rendering matplotlib dan menyalurkannya ke elemen Graphs DOM terisolasi khusus.