Question: ```sql
create procedure sp1
(
    @p1 int = null
)
as
begin
    select f1, f2, f3 
    from table1;
end

```

How to add the "where" clause to the select query (where f1=@p1) only when @p1 is not null? if @p1 is null then return all rows!

Answer: 
The following did the task

```
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')
p_surf=ax.plot_surface(x,y,z,rstride=1,cstride=1,linewidth=0,antialiased=True,facecolors=cm.jet(np.sqrt(x*x + y*y + z*z)))
m = cm.ScalarMappable(cmap=cm.jet)
m.set_array(x*x + y*y + z*z)
plt.colorbar(m)
plt.show()

```
Sorry I cant add this in comment so posting it as a answer.
you should add this to your import according to #Ajean and @PaulH.Then instead of facecolors try cmap.

```
from mpl_toolkits.mplot3d import axes3d, Axes3D

def sph2cart(theta, phi, radius):
    x_cart = radius * np.sin(theta) * np.cos(phi)
    y_cart = radius * np.sin(theta) * np.sin(phi)
    z_cart = radius * np.cos(theta)
    return np.array([x_cart, y_cart, z_cart])

def antenna_plot_3D(mod_F, T, P):
    [x, y, z] = sph2cart(T, P, mod_F)
    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1, projection='3d')
    p_surf = ax.plot_surface(x, y, z, rstride=1, cstride=1,
                         linewidth=0, antialiased=True,
                         cmap=plt.cm.jet)
    ax.set_zlabel('Z axis', fontsize=15)
    ax.set_xlabel('X axis', fontsize=15)
    ax.set_ylabel('Y axis', fontsize=15)
    fig.colorbar(p_surf, shrink=0.5, aspect=5)
    plt.savefig('3d_pattern.png')
    plt.show()

x = 300
t = np.linspace(0, np.pi, num=x)
p = np.linspace(0,2*np.pi, num=x)
[T,P] = np.meshgrid(t,p)
mod_F = np.sin(T) * np.cos(P)
antenna_plot_3D(mod_F, T, P)
plt.show()

```

![result plot](https://i.stack.imgur.com/5eDsg.png)