简体   繁体   中英

How can I get pyplot images to show on a console app?

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.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM