美文网首页
一、Matplotlib 3D图形

一、Matplotlib 3D图形

作者: 垃圾桶边的狗 | 来源:发表于2019-05-21 22:34 被阅读0次
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

#回执3d图形Axes3D
from mpl_toolkits.mplot3d.axes3d import Axes3D
#axes3d模块
from mpl_toolkits.mplot3d import axes3d
x = np.random.randint(0,100,size=100)
y = np.random.randint(0,100,size=100)
z = np.random.randint(-100,0,size=100)

fig = plt.figure(figsize=(6,4))

axes3D = Axes3D(fig)

# axes3D.scatter3D(x,y,z,s = 100 ,color='red')
# axes3D.set_title
28.png
x = np.linspace(0,20,200)
y = np.sin(x)
z = np.cos(x)

fig = plt.figure(figsize=(8,6))
axes3D = Axes3D(fig)

axes3D.plot(x,y,z,color='red')
8.00.png
x = np.array([2001,2003,2005,2007,2009])

y = np.arange(1,13)


fig = plt.figure(figsize=(8,6))
axes3D = Axes3D(fig)

for year in x:
    z = np.random.randint(10,50,size=12)
    axes3D.bar(y,z,zs = year,zdir='x' , color=np.random.rand(12,3))
37.png
x = np.array([2001,2003,2005,2007,2009])

y = np.arange(1,13)

X,Y = np.meshgrid(x,y)
x,y = X.ravel(),Y.ravel()

z = np.zeros_like(x)

top = np.random.randint(0,100,size=72)

fig = plt.figure(figsize=(8,6))
axes3D = Axes3D(fig)

axes3D.bar3d(x,y,z,dx = 1,dy = 1,dz = top)

# a = np.array([1,3,4,5,6,7])
# b = np.array([2,4,6,8,10])

a = np.linspace(0,7,10)
b = np.linspace(0,7,10)
A,B = np.meshgrid(a,b)
# display(a,b)
# display(A,B)

plt.scatter(A,B)
04.png
x = np.linspace(-2,3,110)
y = np.linspace(-2,3,110)

X,Y = np.meshgrid(x,y)

Z = (X**2 + Y**2)**0.5

fig = plt.figure(figsize=(8,6))

axes3D = Axes3D(fig)

axes3D.plot_surface(X,Y,Z)

39.png
X,Y,Z = axes3d.get_test_data()
fig = plt.figure(figsize=(10,4))

axes3D = Axes3D(fig)

surface = axes3D.plot_surface(X,Y,Z,cmap = plt.cm.PuOr)

plt.colorbar(surface,shrink = 0.5)
15.png

相关文章

网友评论

      本文标题:一、Matplotlib 3D图形

      本文链接:https://www.haomeiwen.com/subject/gyzszqtx.html