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: Matplotlib is trending - start learning today
Loading…
💡 Looking to improve your skills? These courses may help—check them out while our AI model processes your request.
📊 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.
Use a multi-file editor, an isolated execution terminal, runtime-specific libraries, persistent workspaces, sharing, and real-time collaboration from the same executor.
How to use this executor?
Choose a runtime, open or create a file, write your code, and select Run. Output appears in the terminal, while signed-in users can keep files in a workspace, install libraries, and collaborate through shares.
- Select a version and edit the current file or open another workspace file.
- Run the code, provide input in the terminal when requested, and review saved run history.
- Use libraries, workspace tools, sharing, and chat when your task needs more than one snippet.
📊 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()