简体   繁体   中英

How could I get the color of the surface to normal yellow for this surface plot?

I am plotting a yellow surface using Python with color='yellow' , here is the codes that I wrote:

import matplotlib.pyplot as plt
import numpy as np
import math
from mpl_toolkits import mplot3d

#Below is the actual plot:
#============================================================================
fig = plt.figure(figsize=(20,10))
ax = fig.add_subplot(1,1,1, projection='3d')
x = np.arange(0,10)
y = np.arange(0,10)
X,Y = np.meshgrid(x,y)
Z = -X**2-Y**2
ax.plot_surface(X, Y, Z,  color='yellow', alpha=.5)

However, what I obtained is a yellow surface looks like this: enter image description here ,

which does not look very yellow.

The yellow color that I am intended to get for the surface should look like this: enter image description here , which could be easily obtained in 2d plots. However, it seems to me that I am unable to obtain this color in 3d surface plots.

Is there any way that I could obtain the normal yellow in the 3d plots? Many thanks in advance for any help and advice!

Try replacing the color string "yellow" in this line:

ax.plot_surface(X, Y, Z,  color='yellow', alpha=.5)

with this:

ax.plot_surface(X, Y, Z,  color='#fcfc03', alpha=.8)

Note the alpha value changed as well, which makes it less transparent but more 'yellow' visually. The alpha value affects how much you can see through it, so find a value that you like!

import matplotlib.pyplot as plt
import numpy as np
import math
from mpl_toolkits import mplot3d

#Below is the actual plot:
#============================================================================
fig = plt.figure(figsize=(20,10))
ax = fig.add_subplot(1,1,1, projection='3d')
x = np.arange(0,10,)
y = np.arange(0,10,)
X,Y = np.meshgrid(x,y)
Z = -X**2-Y**2
ax.plot_surface(X,Y,Z,color='yellow', shade=False)

you can use shade=False and you will get a nice yellow color. Hope that helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM