我有一个元组列表,例如
[("name1",0.05),("name2",0.034),("name3",0.03)....]
我想用
用这些点的线画一个图y0 = 0.05
y1 = 0.034
和
x0 = "name1"
x1 = "name2"
以此类推。
我将如何在python / sage中执行此操作?
答案 0 :(得分:0)
import matplotlib.pyplot as plt
import numpy as np
x = np.array([0,1,2,3])
y = np.array([20,21,22,23])
my_xticks = ['John','Arnold','Mavis','Matt']
plt.xticks(x, my_xticks)
plt.plot(x, y)
plt.show()
对我有很大帮助