1

Suppose I have four one-dimensional numpy arrays, x, y, z, and value. The point (x[i],y[i],z[i]) is part of the surface if and only if value[i]=0. Is there a way to plot this surface in matplotlib?

1 Answer 1

1

you can apply boolean indexing on numpy arrays x,y,z like shown below.

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

x = np.random.random(10)
y = np.random.random(10)
z = np.random.random(10)
value = np.random.randint(2,size=10)

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(x[value==0], y[value==0], z[value==0])
plt.show()

In this example, scatter plot is shown but you can do the same thing for surface plot.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.