I have a functional 3d graph, but I want to make a trace line on the graph for when z = 0.
I tried to split up the graphs for when z>=0 and z<0 but this does not make a clear representation, as shown in code commented out. I want to trace this line in a different color. Another solution would be to have part of the graph z>=0 be one color and z<0 be another color, but I keep getting an error for this as well.
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import numpy as np
def equation(delta=0.05):
#for F=0.5
x = np.arange(0,1,delta)
y = np.arange(2,6,delta)
X,Y = np.meshgrid(x,y)
Z = (X*Y-X-0.5*Y**2+2*0.5*Y)**2-4*(0.5*Y**2-0.5*Y)*(X-X*Y+Y-0.5*Y)
return X, Y, Z
#x = P
#y = K
fig = plt.figure()
ax = Axes3D(fig)
#set labels for graph
ax.set_xlabel('P')
ax.set_ylabel('K')
ax.set_zlabel('Z')
#set colors about and below 0
#c = (Z<=0)
#ax.plot_surface(x,y,z,c=c,cmap='coolwarm')
#ax.plot_surface(x,y,z,c= z<0)
c = z=0
x,y,z = equation(0.01)
surf=ax.plot_surface(x,y,z)
#surf=ax.plot_surface(x,y,z<0)
#surf=ax.plot_surface(x,y,z>=0)
#surf =ax.plot_surface(x,y,z, rstride=5, cstride=5)
#surf = ax.plot_trisurf(x,y,z,cmap=cm.jet,linewidth=0.1,vmin=-15, vmax=100)
#surf = ax.plot_surface(x,y,z,rstride = 5, cstride #=5,cmap=cm.RdBu,linewidth=0, antialiased=False)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
#fig.colorbar(surf, shrink= 0.5, aspect=5)
#ax.view_init(elev=25,azim=-120)
plt.show()