How can I get pyplot images to show on a console app?
-
13-09-2019 - |
Question
I'm trying to create an image using matplotlib.pyplot.imshow()
. However, when I run the program from my console, it doesn't display anything?
This is the code:
import matplotlib.pyplot
myimage = gen_image()
matplotlib.pyplot.gray()
matplotlib.pyplot.imshow(results)
But this shows nothing.
Solution
You have to call the show
function to actually display anything, like
matplotlib.pyplot.show()
Unfortunately the matplotlib documentation seems to be currently broken, so I can't provide a link.
Note that for interactive plotting one typically uses IPython, which has special support for matplotlib.
By the way, you can do
import matplotlib.pyplot as plt
to make the typing less tedious (this is pretty much the official standard way).
OTHER TIPS
You could try http://fishsoup.net/software/reinteract/
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow