Anton_Lambrecht
Anton_Lambrecht

Reputation: 1

I have two lists one for x values and one for y values, I want to make a list from these

I have two lists one for the x values, and one for the y values. The list for the y -values is constantly being updated (see code). I want to make a graph out of these but I don' t know how.

Thank you for the help.

Here is the code I already have:

import time
import matplotlib.pyplot as plt


yvalues = []
xvalues = [0,1,2,3,4,5,6,7,8,9,10]
var = 0
nummer=0
while var < 10 :  # This constructs an infinite loop
   nummer=nummer+1
   yvalues.append(nummer)
   time.sleep(1)
#   print(elements)
   var=var+1


time.sleep(1)

while var==10:
    nummer=nummer+1
    yvalues.append(nummer)
    del yvalues [0]
#    print(elements)
    time.sleep(1)

Upvotes: 0

Views: 207

Answers (1)

Prune
Prune

Reputation: 77837

To make the list of (x,y) pairs, use the Python zip method:

point_list = zip(xvalues, yvalues)

The documentation is here. I assume that you can find a plotting routine in the matplotlib documentation -- or in on-line examples -- without actually needing help from us.

Upvotes: 1

Related Questions