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.
Here is my current 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()
I've read a few examples but couldn't apply them to my data. Is it possible to do this with a for loop?
or something along the lines of:
use_c = {<=0: "red", >=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)
Something that links the value of z to a color.