Search code examples
pythonmatplotlibplotsurface

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!


Solution

  • 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