Pycharm does not show plot

后端 未结 25 1068
鱼传尺愫
鱼传尺愫 2020-12-04 09:13

Pycharm does not show plot from the following code:

import pandas as pd
import numpy as np
import matplotlib as plt

ts = pd.Series(np.random.randn(1000), in         


        
25条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 09:19

    For those who are running a script inside an IDE (and not working in an interactive environment such as a python console or a notebook), I found this to be the most intuitive and the simplest solution:

    plt.imshow(img)
    plt.waitforbuttonpress()
    

    It shows the figure and waits until the user clicks on the new window. Only then it resume the script and run the rest of the code.

提交回复
热议问题