Created
February 21, 2014 17:15
-
-
Save joferkington/9138655 to your computer and use it in GitHub Desktop.
I'm having a bit too much fun with this...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
def main(): | |
t = np.linspace(0, 4*np.pi, 1000) | |
fig, ax = plt.subplots() | |
ax.plot(t, np.cos(t)) | |
ax.plot(t, np.sin(t)) | |
inception(inception(inception(fig))) | |
plt.show() | |
def fig2rgb_array(fig): | |
fig.canvas.draw() | |
buf = fig.canvas.tostring_rgb() | |
ncols, nrows = fig.canvas.get_width_height() | |
return np.fromstring(buf, dtype=np.uint8).reshape(nrows, ncols, 3) | |
def inception(fig): | |
data = fig2rgb_array(fig) | |
fig.clf() | |
fig.add_subplot(111).imshow(data) | |
return fig | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment