Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
I'm having a bit too much fun with this...
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
You can’t perform that action at this time.