Skip to content

Instantly share code, notes, and snippets.

@smathot
Created March 5, 2012 16:08
Show Gist options
  • Save smathot/1979042 to your computer and use it in GitHub Desktop.
Save smathot/1979042 to your computer and use it in GitHub Desktop.
Matplotlib subplot example
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from matplotlib import pyplot
import numpy as np
fig = pyplot.figure()
xData = np.linspace(0, 4*np.pi)
yData = np.sin(xData)
# 3 rows, 2 columns, subplot 2 -> 321
pyplot.subplot("321")
pyplot.plot(xData, yData)
# 3 rows, 2 columns, subplot 2 -> 322
pyplot.subplot("322")
pyplot.plot(xData, yData)
# 3 rows, 2 columns, subplot 3 -> 323
pyplot.subplot("323")
pyplot.plot(xData, yData)
# etc ...
pyplot.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment