Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one draw the X = 0 plane using matplotlib (mpl3d)?

Here is an answer that lets one plot a plane using matplotlib, but if one uses the vector [1, 0, 0], nothing gets plotted! This makes sense, because of the way the code is set up (meshgrid is on X-Y plane, and then Z points determine the surface.

So, how can I plot the X = 0 plane using matplotlib?

like image 594
bzm3r Avatar asked Sep 20 '25 07:09

bzm3r


1 Answers

This is less generic than the example that you linked, but it does the trick:

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

yy, zz = np.meshgrid(range(2), range(2))
xx = yy*0

ax = plt.subplot(projection='3d')
ax.plot_surface(xx, yy, zz)
plt.show()

enter image description here

like image 71
hitzg Avatar answered Sep 22 '25 20:09

hitzg