from math import *
import numpy as np
import matplotlib.pyplot as plt
k = range(11)
yvals = [[] for i in range(len(k))] #there should be a more pythonic way to
x = np.arange(0.4,5,0.1) #create nested lists i think, ALM I added np.
for i in k:
for j in x:
i = float(i) #this conversion from int to float was to debug,
j = float(j) #it should be made better
y=1/(2*j**2) + i/(2*j**2)
i = int(i)
yvals[i].append(y)
for i in k:
plt.plot(x,yvals[i])
plt.show()
从Matplotlib库-他们显示了源代码。你知道吗
这很接近:
http://matplotlib.org/examples/pylab_examples/errorbar_limits.html
http://matplotlib.org/examples/pylab_examples/step_demo.html
http://matplotlib.org/gallery.html
HTH公司
在我看来,最简单的方法之一是使用多维列表存储值,而不是使用matplotlib绘图。这就是我的意思
我想这应该管用。你可以摆弄matplotlib来固定轴,得到标签之类的东西。你知道吗
相关问题 更多 >
编程相关推荐