Matplotlib Code Online Runner – Create and Visualize Python Charts Online
Write and run Matplotlib code in a Python CLI to generate charts—no setup or IDE needed.
Udemy Affiliates: Learn Matplotlib to upgrade your skills
Loading...
📊 About This Matplotlib Online Executor
The CodeUtility Matplotlib Executor allows you to write and run Python code that includes Matplotlib plotting commands — directly in your browser, with no setup or local installation required. It runs real Python environments with Matplotlib preinstalled, enabling instant visual output generation.
This tool uses the latest Matplotlib version and supports typical Python libraries used in data analysis and scientific computing, including NumPy and Pandas.
You can create 2D charts, scatter plots, histograms, or custom visualizations — the tool automatically captures your figure and displays it in a popup window when the code runs successfully.
It’s perfect for learners, data scientists, and engineers who want to quickly experiment with Python visualization code without needing Jupyter Notebook or a local Python setup.
💡 How to Use This Tool
- 1. Select the latest Python + Matplotlib environment from the version dropdown.
- 2. Write or paste your Python code that uses Matplotlib — for example,
import matplotlib.pyplot as plt. - 3. Include
plt.show()in your code to display your chart. - 4. When you click Run, your code executes and the resulting chart opens in a popup window.
- 5. Use Fix Code to automatically correct syntax or formatting issues in your Python code.
- 6. After fixing, a Fixes button appears — click it to review recent corrections.
- 7. You can also Upload local .py files or Download your current code.
- 8. Each run is limited to 20 seconds of execution time to ensure fast and stable rendering.
🧠 Tip: When your code includes plt.show() or other display functions,
the tool automatically renders your Matplotlib figure in a popup window — allowing you to view plots
interactively without cluttering the console output.
📊 Introduction to Matplotlib
1. What is Matplotlib?
Matplotlib is a popular Python library used for creating static, animated, and interactive visualizations. It is especially useful in data science and scientific computing.
import matplotlib.pyplot as plt
2. Line Plot
A basic line chart using X and Y values.
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [2, 4, 6, 8]
plt.plot(x, y)
plt.title("Line Plot")
plt.xlabel("X Axis")
plt.ylabel("Y Axis")
plt.show()
3. Bar Chart
Bar charts are useful for comparing discrete categories.
categories = ['A', 'B', 'C']
values = [5, 7, 3]
plt.bar(categories, values)
plt.title("Bar Chart")
plt.show()
4. Scatter Plot
Use scatter plots to show relationships between two numeric variables.
x = [1, 2, 3, 4]
y = [10, 20, 25, 30]
plt.scatter(x, y)
plt.title("Scatter Plot")
plt.show()
5. Pie Chart
Pie charts are used to show proportions.
labels = ['Apple', 'Banana', 'Cherry']
sizes = [30, 40, 30]
plt.pie(sizes, labels=labels, autopct='%1.1f%%')
plt.title("Fruit Distribution")
plt.show()
6. Histogram
Histograms help understand the distribution of numerical data.
import numpy as np
data = np.random.randn(1000)
plt.hist(data, bins=30)
plt.title("Histogram")
plt.show()
7. Multiple Plots
Plot multiple charts in one figure using subplots.
x = [1, 2, 3, 4]
y1 = [1, 4, 9, 16]
y2 = [2, 3, 5, 7]
plt.subplot(1, 2, 1)
plt.plot(x, y1)
plt.title("Plot 1")
plt.subplot(1, 2, 2)
plt.plot(x, y2)
plt.title("Plot 2")
plt.tight_layout()
plt.show()
8. Customize Styles
You can customize colors, styles, markers, and more.
plt.plot(x, y1, color='red', linestyle='--', marker='o')
plt.title("Styled Line")
plt.show()
9. Save Plot as Image
Save your plot to an image file using savefig().
plt.plot(x, y1)
plt.savefig("my_plot.png")
10. 3D Plot (Advanced)
Matplotlib also supports 3D plotting via mpl_toolkits.mplot3d.
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = [1, 2, 3]
y = [2, 3, 4]
z = [5, 6, 7]
ax.scatter(x, y, z)
plt.show()