gpt4 book ai didi

python - 从Python中的曲面图中删除阴影

转载 作者:行者123 更新时间:2023-12-01 06:03:09 24 4
gpt4 key购买 nike

当我运行附加的 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()

enter image description here

最佳答案

当然,只需将 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()

enter image description here

关于python - 从Python中的曲面图中删除阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9293875/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com