当前位置: 代码迷 >> python >> python matplotlib.pyplot语法错误
  详细解决方案

python matplotlib.pyplot语法错误

热度:75   发布时间:2023-06-13 16:43:15.0

我试图在python中绘制一个函数,但是每次我去测试它时,它只会说:

“ plt.plot(t,V)
^
SyntaxError,语法无效”

from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
import math

def someFunction(filename, posx, posy, posz):
    //generic code
    //to test 
    //limits...
    data = np.genfromtxt(filename,delimiter=",")
    i = 0
    V = 0
    while i < len(data):
        q = data[i,0]
        x = data[i,1]
        y = data[i,2]
        z = data[i,3]
        r = <some computation>
        V += <some computation>
        i += 1

    return V

def plotFunction(filename):
    V = []
    t = []
    for i in np.arange(0,20,0.1):
        t.append(i)
        V.append(someFunction(filename,i,i**2+2,i-3)
    plt.plot(t,V)
    plt.savefig('plot.pdf')

任何帮助将非常感激。

V.append(someFunction(filename,i,i**2+2,i-3))

最后一个右括号缺失