I want to create a 3D surface plot in python, but I am a little confused about how to do this. I have a single line, but I would like the program to plot all possible outputs using all je and be values. Any ideas? I need to find the cartesian product between je and be values, but I think there might be some built-in packages that already do this, but I don't know.
import matplotlib.pyplot as plt
import numpy as np
import scipy as scipy
import math
from scipy.interpolate import interp1d
from scipy.optimize import fsolve
jvals = [[(0.0), 0.0, 0.0],
[0.0, 0.0, 0.0],
[0.0, 0.0, 0.0]]
##########
##This creates the cartesian product of the two array
bvals = [0.1, 0.0, 0.0]
jevals = []
bevals = []
###########################
def Neuro(xyz, bvals, jvals): #redefine function 3 parameters
re = xyz[0]
rp = xyz[1]
rs = xyz[2]
b1 = bvals[0]
b2 = bvals[1]
b3 = bvals[2]
Jee = jvals[0][0]
Jep = jvals[0][1]
Jes = jvals[0][2]
Jpe = jvals[1][0]
Jpp = jvals[1][1]
Jps = jvals[1][2]
Jse = jvals[2][0]
Jsp = jvals[2][1]
Jss = jvals[2][2]
"""
Given:
define ue up us
"""
# print("Original jee value:", jvals[0][0], "and", bvals[0])
# print(Jee, Jep, Jes, b1)
u_e = (((Jee)*re)-((Jep)*rp)-((Jes)*rs)+b1)
u_p = (((Jpe)*re)-((Jpp)*rp)-((Jps)*rs)+b2)
u_s = (Jse)*re + Jsp+ Jss + b3
f_e = -re + (u_e) # add functions
f_p = -rp + (u_p)
f_s = -rs + (u_s)
return f_e, f_p, f_s
############################################### Loop ############################################
num_steps = 100
############################################### Eigen Values ############################################
jevals = np.empty(num_steps)
bevals = np.empty(num_steps)
re = np.empty(num_steps)
rs = np.empty(num_steps)
rp = np.empty(num_steps)
############################################### GRAPHING/Loop ############################################
re[0], rp[0], rs[0] = (0.25,0.20,0.15)
##################Neuro Function loop
for i in range(num_steps):
#Initializes Je and be
jevals[i] = (0.01)*i
bevals[i] = (0.01)*i
jvals[0][0] = jevals[i]
bvals[0] = bevals[i]
xyz0 = np.array([1.0,1,1])
##FSOLVE
xyz0 = np.array([1.0,1,1])
xyz = fsolve(Neuro, xyz0,args = (bvals,jvals))
re[i] =xyz[0::3]
rp[i] =xyz[1::3]
rs[i] =xyz[2::3]
ax = plt.figure().add_subplot(projection='3d')
ax.set_xlabel("Jee Values")
ax.set_ylabel("Be Values")
ax.set_zlabel("Root Values")
ax.set_title("3D Plot")
ax.plot(jevals, bevals, re, 'r')
# ax.plot(jevals, bevals, rp, 'b')
# ax.plot(jevals, bevals, rs, 'g')
#print(jvals[0][0], bvals[0])
plt.show()
#plt.savefig("sim_roots_Jee"+str(jvals[0][0])+"_be"+str(bvals[0])+".png", format='png')
#print(re[i], rp[i], rp[i])
print(jevals[i], bevals[i])
# b_vals[i]
##################