使用Matplotlib在Python中绘制图形

时间:2017-03-11 18:54:29

标签: python matplotlib

我是Python和matplotlib的新手。我试图在Python中绘制方程图,但我不能。你能帮我找出我做错的地方吗?

我的代码在这里:

import matplotlib.pyplot as plt

def plotgraph ():
    T = -14
    index = 0
    ro = []
    while(T<=14):
        ro.append( 1000 - ((T-4)*(T-4)) / 180)
        T = T + 0.001
        plt.plot(ro[index],T)
        index = index +1
    return

plotgraph()
plt.show()

1 个答案:

答案 0 :(得分:3)

以下是使用matplotlib绘制折线图的方法:

import matplotlib.pyplot as plt
import numpy as np

T = np.linspace(-14,14, num=201)
ro = 1000 - ((T-4)*(T-4)) / 180

plt.plot(T, ro)

plt.show()

enter image description here