'Graphs not plotting when in while loop menu

I have created a UI menu inside python by using a while true loop:

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

running it outside the while loop plots the graph just fine, but inside the loop, empty figures show up instead, and then python crashes.

why is it that i can't plot it inside the while loop.

Edit: I have been able to simplify the problem down to this:

import matplotlib.pyplot as plt

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

it seems the while True causes problems. any ideas?



Solution 1:[1]

Try using the plt.show() in the loop

Solution 2:[2]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Subtain Malik
Solution 2 Ran A