在 while 循环菜单中时不绘制图形

Graphs not plotting when in while loop menu

我使用 while true 循环在 python 中创建了一个 UI 菜单:

import matplotlib.pyplot as plt


choice=input('enter a number')
while True:
    if choice == '1':
        pass
    elif choice == '2':
        pass
    elif choice == '3':
        plt.plot(range(100),range(100))
        plt.show()

运行 它在 while 循环之外很好地绘制了图形,但在循环内部,出现了空数字,然后 python 崩溃了。

为什么我不能在 while 循环中绘制它。

编辑: 我已经能够将问题简化为:

import matplotlib.pyplot as plt

x,y=100
while True:
    plt.plot(x,y)

似乎 while True 会导致问题。有什么想法吗?

尝试在循环中使用 plt.show()

import matplotlib.pyplot as plt


choice=input('enter a number')
while True:
    if choice == '1':
        pass
    elif choice == '2':
        pass
    elif choice == '3':
        plt.plot(range(100),range(100))
        plt.show()
    choice=input('enter a number')