Skip to content

Instantly share code, notes, and snippets.

@thillmann50
Created September 19, 2014 20:58
Show Gist options
  • Save thillmann50/29108d14a83bfbca1df7 to your computer and use it in GitHub Desktop.
Save thillmann50/29108d14a83bfbca1df7 to your computer and use it in GitHub Desktop.
MPL Plot.py
# MPL Plot
# A simple demo of using matplotlib in Pythonista.
import console
console.clear()
print 'Generating plot... (this may take a little while)'
import numpy
import matplotlib.pyplot as plt
import math
plt.grid(True)
plt.title('matplotlib Demo')
x = numpy.linspace(0.0, 2 * math.pi)
p1 = plt.plot(x, numpy.sin(x), lw=2, c='r')
p2 = plt.plot(x, numpy.cos(x), lw=2, c='b')
plt.legend([p1[0], p2[0]], ['sin(x)', 'cos(x)'], loc=4)
plt.show()
print 'Tip: You can tap and hold the image to save it to your photo library.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment