- ✕This summary was generated using AI based on multiple online sources. To view the original source information, use the "Learn more" links.
Matplotlib is a Python library for creating static, animated, and interactive visualizations. The most common interface is matplotlib.pyplot, which provides MATLAB-like plotting functions.
Example – Simple Line Plot:
import matplotlib.pyplot as plt# Datax = [1, 2, 3, 4, 5]y = [2, 4, 6, 8, 10]# Create plotplt.plot(x, y, marker='o', color='blue', linestyle='--', label='y = 2x')# Add labels and titleplt.xlabel('X-axis')plt.ylabel('Y-axis')plt.title('Simple Line Plot')plt.legend()# Show plotplt.show()Copied!✕CopyThis code creates a line plot with markers, labels, a title, and a legend. The plt.plot() function is the core method for drawing lines in Matplotlib.
Other Common Plot Types:
Bar Chart:
plt.bar(['A', 'B', 'C'], [5, 7, 3], color='orange')plt.title('Bar Chart Example')plt.show()Copied!✕CopyScatter Plot:
plt.scatter([5, 7, 8], [7, 8, 5], color='red')plt.title('Scatter Plot Example')plt.show()Copied!✕CopyHistogram:
Examples — Matplotlib 3.10.8 documentation
When embedding Matplotlib in a GUI, you must use the Matplotlib API directly rather than the …
See results only from matplotlib.orgLines, bars and markers
Explore examples and tutorials on creating lines, bars, and markers using Matplotlib …
Subplots, axes and figures
Controlling view limits using margins and sticky_edges Axes properties
Pie and polar charts
Nested pie charts A pie and a donut with labels Bar chart on polar axis Polar plot …
Color
Color # For a description of the colormaps available in Matplotlib, see the colormaps …
Images, contours and fields
Explore examples of creating images, contours, and fields using Matplotlib, …
Statistics
Histogram bins, density, and weight Multiple histograms side by side Time …
Text, labels and annotations
Explore Matplotlib's comprehensive guide on text, labels, and annotations for …
Shapes and collections
Drawing fancy boxes Hatch demo Hatch style reference Plot multiple lines using a …
Python Graph Gallery
Explore our curated collection of the finest Python charts, handpicked for their superior design and …
Matplotlib Plotting - W3Schools
By default, the plot() function draws a line from point to point. The function takes parameters for specifying points in the diagram. Parameter 1 is an array …
Graph Plotting in Python | Set 1 - GeeksforGeeks
Jul 23, 2025 · In this example code uses Matplotlib to create a customized line plot. It defines x and y values, and the plot is styled with a green dashed line, a blue …
Pyplot tutorial — Matplotlib 3.10.8 documentation
- alpha: float
- contains: the hit testing function
- clip_box: a matplotlib.transform.Bbox instance
- Introduction to pyplot# matplotlib.pyplot is a collection of functions that make matplotlib work like …
- Plotting with keyword strings# There are some instances where you have data in a format that lets …
- Plotting with categorical variables# It is also possible to create a plot using categorical variables. …
- Controlling line properties# Lines have many attributes that you can set: linewidth, dash style, …
- Working with multiple figures and axes# MATLAB, and pyplot, have the concept of the current …
Python Plotting With Matplotlib (Guide) – Real Python
Dec 1, 2023 · This article is a beginner-to-intermediate-level walkthrough on Python and matplotlib that mixes theory with example.
Data Visualization using Matplotlib in Python
3 days ago · Example: This code demonstrates how to use Figure class to create a simple line plot. It sets figure size and background color, adds custom axes, plots …
Plotting with matplotlib — Practical Data Science with …
You can construct nearly any static plot you can imagine using matplotlib given sufficient patience to do so. Before we dive into how to use this tool, take a look at …
Python Matplotlib Tutorials - Comprehensive Guide for Data ...
Explore Python Matplotlib with tutorials on line graphs, scatter plots, bar charts, and pie charts. Perfect …
Matplotlib - Introduction to Python Plots with Examples
Mar 8, 2022 · Matplotlib Tutorial – A Complete Guide to Python Plot with Examples This tutorial explains matplotlib's way of making python plot, like scatterplots, bar …