0

For example, if we have:

xs = [1, 2, 3, 4, 5, 6, 7, 8, 9]
ys = [1, 2, 3, 4, 5, 6, 7, 8, 9]
name = [a, b, c, d, e, f, g, h, i]
while True:
    user_input = input('Enter name: ')
    for i, j, name in zip(xs, ys, name):
        if(user_input == name):
            ax.scatter(i, j)
            plt.show()

So basically here user enters a name and it gets plotted according to its xs and ys coordinates. How can i make it so that if user enters another name it gets plotted too without losing previous name plot?

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
  • 2
    you need to create a data structure to hold previous user inputs, possibly a list would work hard to tell from the minimal details here. – itprorh66 May 10 '21 at 18:38
  • I would use a (default) dict instead of 3 separate lists. The lookup is way faster, especially if you have a lot of users. Also, you could dynamically add subplots to your plot as is described here: https://stackoverflow.com/questions/12319796/dynamically-add-create-subplots-in-matplotlib . One last thing that you should consider is to explicitly cast your input to whatever type your key is, to avoid unwanted behavior. – DocDriven May 10 '21 at 19:21

0 Answers0