Skip to content

Instantly share code, notes, and snippets.

@zomux
Created October 23, 2014 15:00
Show Gist options
  • Save zomux/7a257ffb6aba6a5228ff to your computer and use it in GitHub Desktop.
Save zomux/7a257ffb6aba6a5228ff 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