How do I plot list of tuples in Python?

后端 未结 5 941
自闭症患者
自闭症患者 2020-12-04 11:03

I have the following data set. I would like to use Python or Gnuplot to plot the data. The tuples are of the form (x, y). The Y-axis should be a log axis, th

5条回答
  •  醉酒成梦
    2020-12-04 11:58

    In matplotlib it would be:

    import matplotlib.pyplot as plt
    
    data =  [(0, 6.0705199999997801e-08), (1, 2.1015700100300739e-08),
     (2, 7.6280656623374823e-09), (3, 5.7348209304555086e-09),
     (4, 3.6812203579604238e-09), (5, 4.1572516753310418e-09)]
    
    x_val = [x[0] for x in data]
    y_val = [x[1] for x in data]
    
    print x_val
    plt.plot(x_val,y_val)
    plt.plot(x_val,y_val,'or')
    plt.show()
    

    which would produce:

    enter image description here

提交回复
热议问题