Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么我们需要将(R,1)重塑为(R,)进行绘图?_Python_Pandas_Numpy_Matplotlib_Plot - Fatal编程技术网

Python 为什么我们需要将(R,1)重塑为(R,)进行绘图?

Python 为什么我们需要将(R,1)重塑为(R,)进行绘图?,python,pandas,numpy,matplotlib,plot,Python,Pandas,Numpy,Matplotlib,Plot,我正在尝试绘制3d绘图 fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot(xs,zs,targets) ax.set_xlabel('xs') ax.set_ylabel('zs') ax.set_zlabel('Targets') ax.view_init(azim=1000) plt.show() 其中,xs的形状为(1000,1),zs的形状为(1000,1),目标的形状为(1000,1)。但由于输

我正在尝试绘制3d绘图

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot(xs,zs,targets)
ax.set_xlabel('xs')
ax.set_ylabel('zs')
ax.set_zlabel('Targets')
ax.view_init(azim=1000)
plt.show()
其中,xs的形状为(1000,1),zs的形状为(1000,1),目标的形状为(1000,1)。但由于
输入操作数的维数超过了轴重新映射所允许的维数,因此获取错误。

如果我们将目标重塑为
targets=targets.reshave(1000,)
,则绘图工作正常。谁能解释一下吗?


因此,3D轴的
绘图
方法的所有输入必须是一维

绘图文档是否说明了其输入的尺寸?我们有xs as(1000,1),但目标as(1000,1)是不可接受的。为什么我们不需要将xs和zs也重塑为(1000,)呢?因为函数不接受2D输入。我同意,但xs和zs的形状(1000,1)是2D的,为什么它们可以接受?因为没有人关心在这种情况下输入错误消息。
plot(self, xs, ys, *args, zdir='z', **kwargs)

Plot 2D or 3D data.

Parameters:   
xs : 1D array-like
     x coordinates of vertices.

ys : 1D array-like
     y coordinates of vertices.

zs : scalar or 1D array-like
     z coordinates of vertices; either one for all points or one for each point