简体   繁体   English

如何绘制2d平面,x轴范围从0到1,y轴范围从0到1,z轴0

[英]how can I plot a 2d plane x axis range from 0 to 1, y axis range from 0 to 1, and z axis 0

I am trying to plot a 3d vector space like this 我想画出像3D矢量空间

here is the code 这是代码

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

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.quiver(0, 0, 0, 0, 1, 0)
ax.quiver(0, 0, 0, 1, 0, 0)
ax.quiver(0, 0, 0, 0, 0, 1)
ax.quiver(0, 0, 0, 1, 1, 1)

limt = 2
ax.set_xlim([-limt, limt])
ax.set_ylim([-limt, limt])
ax.set_zlim([-limt, limt])

ax.set_xlabel('x_axis')
ax.set_ylabel('y_axis')
ax.set_zlabel('z_axis')
plt.show()

在此处输入图片说明

I've finished the vectors (a line with an arrow) part, how can I plot a 2d plane x axis range from 0 to 1, y axis range from 0 to 1, and z axis 0? 我已经完成了矢量(带箭头的线)部分,如何绘制二维平面x轴范围从0到1,y轴范围从0到1,z轴0?

plot_surface may meet your need. plot_surface可能满足您的需求。

xx, yy = np.meshgrid(np.arange(0,1,.1), np.arange(0,1,.1))
zz = np.zeros((10,10))
ax.plot_surface(xx, yy, zz, alpha=0.5)

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 熊猫:如何在1到12月的月份中标记x轴上的刻度线,并限制y轴上的范围? - Pandas: How can I label ticks on x-axis with months from Jan to Dec and limit the range on the y-axis? 如何设置热图的X和Y轴范围? - How Can I Set The Range Of the X and Y Axis For A Heatmap? 在 python - 我如何 plot 2D 图(x,y)并通过每个(x,y)坐标的颜色变化添加第三轴? - In python - How can I plot 2D figure (x,y) and add 3rd axis by variation of the colour for each (x,y)-coordinate? 为什么不能在Pandas系列生成的绘图上设置y轴范围? - Why can't I set the y-axis range on a plot produced from a Pandas Series? 如何更改matlibplot中x轴和y轴的范围? - How to change the range of the x-axis and y-axis in matlibplot? 我该如何用文字确定范围并使其在图的y轴上 - how can I make range with text and make this to y-axis in plot 即使我没有数据,如何增加概率密度 plot 的 x 轴范围? - How can I increase range of x-axis in probability density plot even If I have no data for that? 如何在Python中从数据框绘制带有x和y轴的直方图 - How to plot histogram with x and y axis from dataframe in python Sympy-更改图的y轴范围 - Sympy - altering the range of the y axis for a plot 倾斜轴2D图,其中xy轴成60度而不是90度 - tilted axis 2D plot where x y axis make 60 degree rather than 90
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM