我正在尝试将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中使用joblib来加快某些数据处理的速度,但是在尝试确定如何将输出分配为所需格式时遇到了问题。我试图生成一个也许过于简单的代码来显示我所遇到的问题:
from joblib import Parallel, delayed
import numpy as np
def main():
print "Nested loop array assignment:"
regular()
print "Parallel nested loop assignment using a single process:"
par2(1)
print "Parallel nested loop assignment using multiple process:"
par2(2)
def regular():
# Define variables
a = [0,1,2,3,4]
b = [0,1,2,3,4]
# Set array variable to global and define size and shape
global ab
ab = np.zeros((2,np.size(a),np.size(b)))
# Iterate to populate array
for i in range(0,np.size(a)):
for j in range(0,np.size(b)):
func(i,j,a,b)
# Show …Run Code Online (Sandbox Code Playgroud)