当我运行附加的python代码(其中一些是我试图生成的图中遗留的垃圾)时,我得到一个有两个阴影的表面。 (深红色和浅红色),有没有办法把它变成单一的阴影?
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import sys
from math import sqrt,exp,log, sin
from pylab import rcParams
rcParams['figure.figsize'] = 30,26
fig = plt.figure()
ax = fig.add_subplot(211, projection='3d')
l = 7
sigma = 1.0/277.450924284104 #You are stupid so have found the charge density for surface potentail of exactly 62mV
pi = 3.14159
b = 1.0/(2*pi*sigma*l)
lambdaD = 9.5
X0, Y0 = np.mgrid[0:1:100j, 0:1:100j]
Z0 = np.zeros_like(X0)
for i in range(0,len(X0)):
for j in range (0, len(X0[i])):
Z0[i][j] = 10*sin(X0[i][j]*2*pi)
ax.plot_surface(X0,Y0,Z0,color='red', linewidth=0, rstride=10, cstride=10, antialiased=False)
ax.set_axis_off()
答案 0 :(得分:2)
当然,只需将shade=False
指定为ax.plot_surface
。
此外,绝对不需要使用嵌套for循环或通过rcParams
指定数字大小。
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(30, 26))
ax = fig.add_subplot(111, projection='3d')
X0, Y0 = np.mgrid[0:1:100j, 0:1:100j]
Z0 = 10 * np.sin(X0 * 2 * np.pi)
ax.plot_surface(X0,Y0,Z0,color='red', linewidth=0, rstride=10, cstride=10,
antialiased=False, shade=False)
ax.set_axis_off()
plt.show()