matplotlib
DataChart rendering
What is matplotlib?
Matplotlib is Python's most widely used plotting library. It lets you create publication-quality 2D charts — bar charts, line plots, scatter plots, histograms, pie charts, and much more — with just a few lines of code. Matplotlib integrates tightly with NumPy and Pandas, making it the default visualisation layer for nearly all data science workflows.
PyRun renders Matplotlib charts directly in the browser inside a dedicated GRAPHS tab. When your code calls plt.show(), PyRun intercepts the figure and displays it as a crisp SVG alongside your terminal output. There's no need for a Jupyter notebook or a local display server — just write your plotting code and run it.
Code Example
Renders a chart in the GRAPHS tab.
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()Why run matplotlib in PyRun?
- ✦ Zero setup — no pip install, no virtual environment, no Python download
- ✦ Instant results — powered by WebAssembly, runs locally in your browser
- ✦ Share your code — generate a link and anyone can run it instantly
- ✦ Works offline — after first load, PyRun runs without internet
Related Packages
Recommended Python Resources
Expand your knowledge with related interactive tutorials, cheat sheets, and code comparisons.
Python Loops
Learn how to use Python loops to iterate over data. Master for loops, while loops, break, continue, and loop best practices with interactive examples.
How to Sort a List in Python
Learn how to sort a list in Python using the sort() method and the sorted() function. Discover custom key sorting and reverse order examples.
Python String Methods
A complete reference guide for Python string manipulation. Master formatting, searching, splitting, replacing, and checking string properties.
Python vs JavaScript: Which Programming Language is Best?
A comprehensive comparison between Python and JavaScript. Explore syntax differences, performance, use cases (backend vs frontend), and coding examples.