相关疑难解决方法(0)

在python mplot3D中,2D图不会与3D轴壁齐平

我正在尝试将2D数据绘制到3D轴上.我使用了3D形状,ax.plot_surface但是我无法使2D数据与轴墙齐平ax.plot.

这是一个精简的示例代码,显示了我对2D数据的问题:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Generate Example Data
x = [0.04,0,-0.04]
y = [0.04,0,-0.04]
z = [0.04,0,-0.04]

# Start plotting environment
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Plot 3 lines positioned against the axes "walls"
ax.plot(x,y,-0.08,zdir='z',c='r')
ax.plot(x,z, 0.08,zdir='y',c='g')
ax.plot(y,z,-0.08,zdir='x',c='b')

# Label each axis
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')

# Set each axis limits
ax.set_xlim([-0.08,0.08])
ax.set_ylim([-0.08,0.08]) 
ax.set_zlim([-0.08,0.08]) 

# Equally stretch all axes
ax.set_aspect("equal")

# Set plot size for saving to disk …
Run Code Online (Sandbox Code Playgroud)

python matplotlib python-2.7 mplot3d

10
推荐指数
1
解决办法
929
查看次数

标签 统计

matplotlib ×1

mplot3d ×1

python ×1

python-2.7 ×1