matplotlib 3D plot color coding by value range
<p>I am trying to produce a 3D plot with two colors. One color for values above zero and another color for values below zero. I just cannot figure out how to implement this in the code. </p>

<p>Here is my current code: </p>

<pre><code>from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
import matplotlib.tri as mtri
import pandas as pd
import numpy as np

df = pd.DataFrame.from_csv('...temp\\3ddata.csv', sep = ',', index_col  = False)

fig = plt.figure()
ax = fig.gca(projection='3d')

x = df['P']
y = df['T']
z = df['S']

ax.plot(x, y, zs= 0, zdir = 'z', c= 'r')

ax.scatter(x,y, z, c = 'b', s = 20)

ax.set_xlabel('Pressure (Bar)')
ax.set_zlabel('Residual subcooling (J*Kg-1*K-1')
ax.set_ylabel('Temperaure of LNG (K)')

plt.show()
</code></pre>

<p><a href="https://i.stack.imgur.com/ytUEE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ytUEE.png" alt="3DPLOT"></a></p>

<p>I've read a few examples but couldn't apply them to my data. Is it possible to do this with a for loop? </p>

<p>or something along the lines of:</p>

<pre><code>use_c = {&lt;=0: "red", &gt;=0 "blue"}

#ax.plot(x, y, zs= 0, zdir = 'z', c= 'r')

ax.scatter(x,y, z, c = [use_c[x[0]] for x in z], s = 20)
</code></pre>

<p>Something that links the value of z to a color. </p>