GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python-data-visualization/Matplotlib at main · javedali99/python-data-visualization

Expand file tree

/

Matplotlib

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

Matplotlib

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Data
Data
 
 
animate_linePlot_matplotlib
animate_linePlot_matplotlib
 
 
data viz notebooks
data viz notebooks
 
 
matplotlib-plots-gallery
matplotlib-plots-gallery
 
 
raincloud_matplotlib_py
raincloud_matplotlib_py
 
 
wealth
wealth
 
 
Data visualization with matplotlib.ipynb
Data visualization with matplotlib.ipynb
 
 
Introduction to matplotlib for data visualization.ipynb
Introduction to matplotlib for data visualization.ipynb
 
 
Making Economist Style Plots in Matplotlib.ipynb
Making Economist Style Plots in Matplotlib.ipynb
 
 
Matplotlib tutorial.ipynb
Matplotlib tutorial.ipynb
 
 
README.md
README.md
 
 
The-magic-of-Matplotlib-stylesheets.zip
The-magic-of-Matplotlib-stylesheets.zip
 
 
all-about-vis-how-to-make-the-right-lineplot.ipynb
all-about-vis-how-to-make-the-right-lineplot.ipynb
 
 
all-you-need-is-time-series-visualization-20.ipynb
all-you-need-is-time-series-visualization-20.ipynb
 
 
anatomy.ipynb
anatomy.ipynb
 
 
anatomy.webp
anatomy.webp
 
 
arranging_axes.ipynb
arranging_axes.ipynb
 
 
awesome-new-in-matplotlib-3-4-0.ipynb
awesome-new-in-matplotlib-3-4-0.ipynb
 
 
dark-mode-visualization-apple-version.ipynb
dark-mode-visualization-apple-version.ipynb
 
 
matplotlib-animation-techniques-2.ipynb
matplotlib-animation-techniques-2.ipynb
 
 
matplotlib-animation-techniques.ipynb
matplotlib-animation-techniques.ipynb
 
 
matplotlib-bag-of-tricks-advanced-techniques.ipynb
matplotlib-bag-of-tricks-advanced-techniques.ipynb
 
 
matplotlib-conceptual-figure-basic-viz.ipynb
matplotlib-conceptual-figure-basic-viz.ipynb
 
 
plot-wp-graph.py
plot-wp-graph.py
 
 
pokemon-visualization-with-matplotlib.ipynb
pokemon-visualization-with-matplotlib.ipynb
 
 
simple-matplotlib-visualization-tips.ipynb
simple-matplotlib-visualization-tips.ipynb
 
 
subfigures.ipynb
subfigures.ipynb
 
 

README.md

Outline

Subplotting

Arranging multiple Axes in a Figure

Often more than one Axes is wanted on a figure at a time, usually organized into a regular grid. Matplotlib has a variety of tools for working with grids of Axes that have evolved over the history of the library. Here we will discuss the tools we think users should use most often, the tools that underpin how Axes are organized, and mention some of the older tools.

Jupyter Notebook

Figure subfigures

Sometimes it is desirable to have a figure with two different layouts in it. This can be achieved with nested gridspecs, but having a virtual figure with its own artists is helpful, so Matplotlib also has subfigures, accessed by calling matplotlib.figure.Figure.add_subfigure in a way that is analogous to matplotlib.figure.Figure.add_subplot, or matplotlib.figure.Figure.subfigures to make an array of subfigures. Note that subfigures can also have their own child subfigures.

Jupyter Notebook

Tutorial on Plot Organization in matplotlib — Your One-stop Guide

A brief tutorial on how to organize multiple subplots with different positions and sizes on matplotlib.

Jupyter Notebook

Creating Subplots in Matplotlib

import matplotlib.pyplot as plt

python_course_green = "#476042"
fig = plt.figure(figsize=(6, 4))
sub1 = plt.subplot(2, 2, 1)
sub1.set_xticks(())
sub1.set_yticks(())
sub1.text(0.5, 0.5, 'subplot(2,2,1)', ha='center', va='center',
        size=20, alpha=.5)

sub2 = plt.subplot(2, 2, 2)
sub2.set_xticks(())
sub2.set_yticks(())
sub2.text(0.5, 0.5, 'subplot(2,2,2)', ha='center', va='center',
        size=20, alpha=.5)

sub3 = plt.subplot(2, 2, 3)
sub3.set_xticks(())
sub3.set_yticks(())
sub3.text(0.5, 0.5, 'subplot(2,2,3)', ha='center', va='center',
        size=20, alpha=.5)

sub4 = plt.subplot(2, 2, 4, facecolor=python_course_green)
sub4.set_xticks(())
sub4.set_yticks(())
sub4.text(0.5, 0.5, 'subplot(2,2,4)', ha='center', va='center',
        size=20, alpha=.5, color="y")

fig.tight_layout()
plt.show()

subplots-in-Python

import numpy as np
from numpy import e, pi, sin, exp, cos
import matplotlib.pyplot as plt

def f(t):
    return exp(-t) * cos(2*pi*t)

def fp(t):
    return -2*pi * exp(-t) * sin(2*pi*t) - e**(-t)*cos(2*pi*t)

def g(t):
    return sin(t) * cos(1/(t+0.1))

def g(t):
    return sin(t) * cos(1/(t))


python_course_green = "#476042"
fig = plt.figure(figsize=(6, 4))

t = np.arange(-5.0, 1.0, 0.1)

sub1 = fig.add_subplot(221) # instead of plt.subplot(2, 2, 1)
sub1.set_title('The function f') # non OOP: plt.title('The function f')
sub1.plot(t, f(t))


sub2 = fig.add_subplot(222, facecolor="lightgrey")
sub2.set_title('fp, the derivation of f')
sub2.plot(t, fp(t))


t = np.arange(-3.0, 2.0, 0.02)
sub3 = fig.add_subplot(223)
sub3.set_title('The function g')
sub3.plot(t, g(t))

t = np.arange(-0.2, 0.2, 0.001)
sub4 = fig.add_subplot(224, facecolor="lightgrey")
sub4.set_title('A closer look at g')
sub4.set_xticks([-0.2, -0.1, 0, 0.1, 0.2])
sub4.set_yticks([-0.15, -0.1, 0, 0.1, 0.15])
sub4.plot(t, g(t))

plt.plot(t, g(t))

plt.tight_layout()
plt.show()

subplots-in-Python

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.