如何使用 matplotlib (mpl3d) 绘制 X = 0 平面? [英] How does one draw the X = 0 plane using matplotlib (mpl3d)?
本文介绍了如何使用 matplotlib (mpl3d) 绘制 X = 0 平面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里有一个答案,可以使用 matplotlib
绘制平面,但如果使用向量 [1, 0, 0]
,没有绘制任何内容!这是有道理的,因为代码的设置方式(网格在 X-Y 平面上,然后 Z 点确定表面.
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.
那么,如何使用matplotlib绘制X = 0平面?
So, how can I plot the X = 0 plane using matplotlib?
推荐答案
这不像您链接的示例那么通用,但它确实有用:
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()
这篇关于如何使用 matplotlib (mpl3d) 绘制 X = 0 平面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文