Python图只绘制一个点

时间:2017-10-11 18:56:32

标签: python python-3.x matplotlib plot graph

目前我正在尝试使用参数L绘制madelung常量。获得的值是正确的,但是当我尝试绘制图形时,它只显示一个点。我假设它要么没有绘制所有的点,要么放大了太多。This is the plot obtained from the code

from math import sqrt
from pylab import plot, show
import numpy 

def madelung(L):

    M = 0.0

    for i in range(-L,L+1):

        for j in range(-L,L+1):         

            for k in range(-L,L+1):

                if not (i==j==k==0):

                    M += ((-1)**(i+j+k+1))/sqrt(i*i +j*j +k*k)

    return M

list = []
L = 0

while int(L) < 30:
    list.append(L)
    L = int(L) + 1

plot(L, madelung(L), color='green', marker='o')
show()

0 个答案:

没有答案