首页 > 解决方案 > Matplotlib 没有绘制所有数据点

问题描述

我面临一个问题,我有 13 个数据点,但 Matplotlib 只能绘制到大约 8-9 个数据点。下面是我的代码:

import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
import numpy as np

pv = [1240, 1390, 1635, 1885, 2025, 2165, 2290, 2965, 3455, 4510, 4975, 5510, 5795]
ac = [1200, 1325, 1555, 1835, 1985, 2135, 2285, 2435, 2985]
ev = [1240, 1390, 1635, 1885, 2025, 2165, 2165, 2165, 2690]
time = np.arange(1, 14)
y1 = np.zeros(13)

fig = plt.figure(figsize=(10,5))
ax = plt.axes(projection='3d')
ax.plot(xs=time, ys=y1, zs=pv, label="PV")
ax.plot(xs=time[0: 9], ys=(y1+1)[0: 9], zs=ac, label="AC")
ax.plot(xs=time[0: 9], ys=(y1+2)[0: 9], zs=ev, label="EV")
ax.set_yticklabels([])
ax.set_xticks(time)
ax.set_title("Earned Value Analysis")

ax.set_xlabel("Time(Week)")
ax.set_zlabel("Cummulative Cost")
plt.legend(loc="lower right")

plt.show()

这是我的程序的输出: 输出

在 13 时,我的 PV 应该在 5795 左右。但是,该图仅绘制到 8-9 时左右。感谢任何人清除我的疑问。

标签: pythonmatplotlib

解决方案


推荐阅读