失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > python【Matlibplot绘图库】-绘制三维图像

python【Matlibplot绘图库】-绘制三维图像

时间:2024-07-14 14:12:42

相关推荐

python【Matlibplot绘图库】-绘制三维图像

文章目录

1.绘制三维图像2.plt.axes()

1.绘制三维图像

import matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dfig = plt.figure()ax = fig.add_subplot(111, projection='3d')X = [1, 1, 2, 2]Y = [3, 4, 4, 3]Z = [1, 2, 1, 1]ax.plot_trisurf(X, Y, Z)plt.show()

2.plt.axes()

我们先来看什么是Figure和Axes对象。在matplotlib中,整个图像为一个Figure对象。在Figure对象中可以包含一个,或者多个Axes对象。每个Axes对象都是一个拥有自己坐标系统的绘图区域。其逻辑关系如下:

import matplotlib.pyplot as pltimport numpy as np# create some data to use for the plotdt = 0.001t = np.arange(0.0, 10.0, dt)r = np.exp(-t[:1000] / 0.05) # impulse responsex = np.random.randn(len(t))s = np.convolve(x, r)[:len(x)] * dt # colored noise# the main axes is subplot(111) by defaultplt.plot(t, s)plt.axis([0, 1, 1.1 * np.amin(s), 2 * np.amax(s)])plt.xlabel('time (s)')plt.ylabel('current (nA)')plt.title('Gaussian colored noise')# this is an inset axes over the main axesa = plt.axes([.65, .6, .2, .2], axisbg='y')n, bins, patches = plt.hist(s, 400, normed=1)plt.title('Probability')plt.xticks([])plt.yticks([])# this is another inset axes over the main axesa = plt.axes([0.2, 0.6, .2, .2], axisbg='y')plt.plot(t[:len(r)], r)plt.title('Impulse response')plt.xlim(0, 0.2)plt.xticks([])plt.yticks([])plt.show()

如果觉得《python【Matlibplot绘图库】-绘制三维图像》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。