中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

四川省建設(shè)信息網(wǎng)站貴州seo學(xué)校

四川省建設(shè)信息網(wǎng)站,貴州seo學(xué)校,企業(yè)注冊登記信息查詢,wordpress簡體切換目錄線狀堆積圖 PolygonPlot三維表面圖 SurfacePlot散點圖ScatterPlot柱形圖 BarPlot三維直方圖螺旋曲線圖 LinePlotContourPlot輪廓圖網(wǎng)狀圖 WireframePlot箭頭圖二維三維合并文本圖Text三維多個子圖線狀堆積圖 PolygonPlot Axes3D.add_collection3d(col, zs0, zdir‘z’) ?…

目錄

      • 線狀堆積圖 PolygonPlot
      • 三維表面圖 SurfacePlot
      • 散點圖ScatterPlot
      • 柱形圖 BarPlot
      • 三維直方圖
      • 螺旋曲線圖 LinePlot
      • ContourPlot
      • 輪廓圖
      • 網(wǎng)狀圖 WireframePlot
      • 箭頭圖
      • 二維三維合并
      • 文本圖Text
      • 三維多個子圖

線狀堆積圖 PolygonPlot

Axes3D.add_collection3d(col, zs=0, zdir=‘z’)
???這個函數(shù)可以將三維 collection對象或二維collection對象加入到一個圖形中,包括:

  • PolyCollection
  • LineCollection
  • PatchCollection
import pandas as pd
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.collections import PolyCollection
import matplotlib.pyplot as plt
from matplotlib import colors as mcolors
import numpy as np
plt.rcParams['font.family'] = 'Microsoft YaHei' # 字體設(shè)置
plt.rcParams['font.size'] = 10 # 字體大小設(shè)置fig = plt.figure(figsize=(30,20))
ax = fig.gca(projection='3d')def cc(arg):return mcolors.to_rgba(arg, alpha=0.6)
def polygon_under_graph(xlist, ylist):'''Construct the vertex list which defines the polygon filling the space underthe (xlist, ylist) line graph.  Assumes the xs are in ascending order.'''return [(xlist[0], 0.), *zip(xlist, ylist), (xlist[-1], 0.)]xs = np.arange(0,137,1)verts = []zs = [0.0,1.0,2.0, 3.0,4.0]
for z in zs:for i in range(1,6):   #讀取數(shù)據(jù)ys = df.iloc[:,i]verts.append(polygon_under_graph(xs,ys))poly = PolyCollection(verts, facecolors=[cc('r'), cc('g'), cc('b'),cc('y'),cc('r')])
poly.set_alpha(0.7)  # 圖形的透明度
ax.add_collection3d(poly, zs=zs, zdir='y')names_1 = ['2022-10-18', '2022-10-19', '2022-10-20','2022-10-21',
'2022-10-22', '2022-10-23']
plt.xticks(xs[::24], names_1)names = ['北京', '石家莊', '保定','唐山','廊坊']
plt.yticks(zs, names)ax.set_xlabel('時間')
ax.set_ylabel('城市')
ax.set_zlabel('AQI')
ax.set_xlim3d(0, 136)
ax.set_ylim3d(-1, 5)
ax.set_zlim3d(0, 130)
#plt.savefig('三維時間.png',bbox_inches = 'tight',dpi=500)
plt.show()

在這里插入圖片描述

三維表面圖 SurfacePlot

Axes3D.plot_surface(X, Y, Z, *args, norm=None, vmin=None, vmax=None, lightsource=None, **kwargs)

這個函數(shù)算是比較常用的函數(shù),用于繪制三維表面圖,讓人驚艷的是它的著色效果。

ArgumentDescription
X, Y,Z坐標(biāo)點
rcount,ccount,rstride,cstride同上
color定義surface patch的顏色,type:color-like
cmap定義surface patch的顏色,只不過是colorMap,type:colormap
facecolors指定單個patch的顏色, type:array-like of colors
normcolormap的normalization, type:Normalize
shade陰影效果,type:boolean
vmin, vmaxnormalization的邊界
**kwargs向下傳遞到Poly3DCollection
antialiased抗鋸齒,type:boolean
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cmfrom matplotlib.ticker import LinearLocator, FormatStrFormatter
import numpy as npfig = plt.figure(figsize=(30,10))
ax = fig.gca(projection='3d')# Make data.
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)# Plot the surface.
surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,linewidth=0, antialiased=False)# Customize the z axis.
ax.set_zlim(-1.01, 1.01)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))# Add a color bar which maps values to colors.
fig.colorbar(surf, shrink=0.5, aspect=5)plt.show()

在這里插入圖片描述

散點圖ScatterPlot

Axes3D.scatter(xs, ys, zs=0, zdir=‘z’, s=20, c=None, depthshade=True, *args, **kwargs)

返回Patch3DCollection,

其他參數(shù)向下傳遞給plot函數(shù)

ArgumentDescription
xs, ysx,y坐標(biāo)點
zsz 坐標(biāo),可以是一個標(biāo)量或一個x*y維矩陣,默認(rèn)是0.
zdir當(dāng)繪制二維圖像時的z軸方向
ssize,即散點大小
c顏色映射,其取值可以是非常多類型,有時間專門寫一篇講解
depthshade是否渲染景深(或則就說陰影吧),默認(rèn)是True.
from mpl_toolkits.mplot3d import Axes3Dimport matplotlib.pyplot as plt
import numpy as np# Fixing random state for reproducibility
np.random.seed(19680801)def randrange(n, vmin, vmax):'''Helper function to make an array of random numbers having shape (n, )with each number distributed Uniform(vmin, vmax).'''return (vmax - vmin)*np.random.rand(n) + vminfig = plt.figure(figsize=(20,10))
ax = fig.add_subplot(111, projection='3d')n = 100# For each set of style and range settings, plot n random points in the box
# defined by x in [23, 32], y in [0, 100], z in [zlow, zhigh].
for c, m, zlow, zhigh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]:xs = randrange(n, 23, 32)ys = randrange(n, 0, 100)zs = randrange(n, zlow, zhigh)ax.scatter(xs, ys, zs, c=c, marker=m)ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')plt.show()

在這里插入圖片描述

柱形圖 BarPlot

Axes3D.bar(left, height, zs=0, zdir=‘z’, *args, **kwargs)

其他參數(shù)向下傳遞給bar函數(shù),返回Patch3DCollection對象

ArgumentDescription
left條形圖水平坐標(biāo)
height條形的高度
zsZ方向
zdir同上
from mpl_toolkits.mplot3d import Axes3D  # noqa: F401 unused importimport matplotlib.pyplot as plt
import numpy as np# Fixing random state for reproducibility
np.random.seed(19680801)fig = plt.figure(figsize=(10,20))
ax = fig.add_subplot(111, projection='3d')colors = ['r', 'g', 'b', 'y']
yticks = [3, 2, 1, 0]
for c, k in zip(colors, yticks):# Generate the random data for the y=k 'layer'.xs = np.arange(20)ys = np.random.rand(20)# You can provide either a single color or an array with the same length as# xs and ys. To demonstrate this, we color the first bar of each set cyan.cs = [c] * len(xs)# Plot the bar graph given by xs and ys on the plane y=k with 80% opacity.ax.bar(xs, ys, zs=k, zdir='y', color=cs, alpha=0.8)ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')# On the y axis let's only label the discrete values that we have data for.
ax.set_yticks(yticks)plt.show()

在這里插入圖片描述

三維直方圖

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as npfig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x, y = np.random.rand(2, 100) * 4
hist, xedges, yedges = np.histogram2d(x, y, bins=4, range=[[0, 4], [0, 4]])# Construct arrays for the anchor positions of the 16 bars.
# Note: np.meshgrid gives arrays in (ny, nx) so we use 'F' to flatten xpos,
# ypos in column-major order. For numpy >= 1.7, we could instead call meshgrid
# with indexing='ij'.
xpos, ypos = np.meshgrid(xedges[:-1] + 0.25, yedges[:-1] + 0.25)
xpos = xpos.flatten('F')
ypos = ypos.flatten('F')
zpos = np.zeros_like(xpos)# Construct arrays with the dimensions for the 16 bars.
dx = 0.5 * np.ones_like(zpos)
dy = dx.copy()
dz = hist.flatten()ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='b', zsort='average')plt.show()

在這里插入圖片描述

螺旋曲線圖 LinePlot

Axes3D.plot(xs, ys, *args, zdir=‘z’, **kwargs)

其他參數(shù)向下傳遞給plot函數(shù)

ArgumentDescription
xs, ysx、y 坐標(biāo)
zsz 坐標(biāo),可以是一個標(biāo)量或一個x*y維矩陣
zdir當(dāng)繪制二維圖像時的z軸方向
from mpl_toolkits.mplot3d import Axes3Dimport numpy as np
import matplotlib.pyplot as pltplt.rcParams['legend.fontsize'] = 10
fig = plt.figure(figsize=(10,20))
ax = fig.gca(projection='3d')  # get current axes# Prepare arrays x, y, z
theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
z = np.linspace(-2, 2, 100)
r = z**2 + 1
x = r * np.sin(theta)
y = r * np.cos(theta)ax.plot(x, y, z, label='parametric curve')
ax.legend()  plt.show()

在這里插入圖片描述

ContourPlot

Axes3D.contour(X, Y, Z, *args, extend3d=False, stride=5, zdir=‘z’, offset=None, **kwargs)

ArgumentDescription
X, Y,ZData values as numpy.arrays
extend3d是否延申到3d空間 (default: False)
*stride(extend3d的)采樣步長
zdir同上
offset繪制輪廓線在zdir垂直的水平面上的投影
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cmfig = plt.figure(figsize=(30,10))
ax = fig.gca(projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)# Plot contour curves
cset = ax.contour(X, Y, Z, cmap=cm.coolwarm)ax.clabel(cset, fontsize=9, inline=1)  # function to label a contourplt.show()

在這里插入圖片描述

輪廓圖


from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cmfig = plt.figure()
ax = fig.gca(projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)
cset = ax.contour(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm)
cset = ax.contour(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm)
cset = ax.contour(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm)ax.set_xlabel('X')
ax.set_xlim(-40, 40)
ax.set_ylabel('Y')
ax.set_ylim(-40, 40)
ax.set_zlabel('Z')
ax.set_zlim(-100, 100)plt.show()

在這里插入圖片描述

網(wǎng)狀圖 WireframePlot

Axes3D.plot_wireframe(X, Y, Z, *args, **kwargs)

ArgumentDescription
X, Y,Z坐標(biāo)點
rcount,ccount采樣數(shù),越大采樣越多,默認(rèn)50
rstride,cstride采樣步長,越小采樣越多
**kwargs其他參數(shù)向下傳入Line3DCollection
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as pltfig = plt.figure(figsize=(30,10))
ax = fig.add_subplot(111, projection='3d')# Grab some test data.
X, Y, Z = axes3d.get_test_data(0.05)# Plot a basic wireframe.
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)plt.show()

在這里插入圖片描述

箭頭圖

Axes3D.quiver(*args, **kwargs)

ArgumentDescription
X, Y, ZThe x, y and z coordinates of the arrow locations (default is tail of arrow; see pivot kwarg)
U, V, WThe x, y and z components of the arrow vectors
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as npfig = plt.figure()
ax = fig.gca(projection='3d')# Make the grid
x, y, z = np.meshgrid(np.arange(-0.8, 1, 0.2),np.arange(-0.8, 1, 0.2),np.arange(-0.8, 1, 0.8))# Make the direction data for the arrows
u = np.sin(np.pi * x) * np.cos(np.pi * y) * np.cos(np.pi * z)
v = -np.cos(np.pi * x) * np.sin(np.pi * y) * np.cos(np.pi * z)
w = (np.sqrt(2.0 / 3.0) * np.cos(np.pi * x) * np.cos(np.pi * y) *np.sin(np.pi * z))ax.quiver(x, y, z, u, v, w, length=0.1, normalize=True)plt.show()

在這里插入圖片描述

二維三維合并

from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as pltfig = plt.figure()
ax = fig.gca(projection='3d')# Plot a sin curve using the x and y axes.
x = np.linspace(0, 1, 100)
y = np.sin(x * 2 * np.pi) / 2 + 0.5
ax.plot(x, y, zs=0, zdir='z', label='curve in (x,y)')# Plot scatterplot data (20 2D points per colour) on the x and z axes.
colors = ('r', 'g', 'b', 'k')
x = np.random.sample(20 * len(colors))
y = np.random.sample(20 * len(colors))
labels = np.random.randint(3, size=80)# By using zdir='y', the y value of these points is fixed to the zs value 0
# and the (x,y) points are plotted on the x and z axes.
ax.scatter(x, y, zs=0, zdir='y', c=labels, label='points in (x,z)')# Make legend, set axes limits and labels
ax.legend()
ax.set_xlim(0, 1)
ax.set_ylim(0, 1)
ax.set_zlim(0, 1)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')# Customize the view angle so it's easier to see that the scatter points lie
# on the plane y=0
ax.view_init(elev=20., azim=-35)plt.show()

在這里插入圖片描述

文本圖Text

Axes3D.text(x, y, z, s, zdir=None, **kwargs)

text的內(nèi)容其實也很繁雜,需要用一篇內(nèi)容去探討,在三維中很重要的一點是要學(xué)會二維、三維文字的添加。

from mpl_toolkits.mplot3d import Axes3D  # noqa: F401 unused importimport matplotlib.pyplot as pltfig = plt.figure()
ax = fig.gca(projection='3d')# Demo 1: zdir
zdirs = (None, 'x', 'y', 'z', (1, 1, 0), (1, 1, 1))
xs = (1, 4, 4, 9, 4, 1)
ys = (2, 5, 8, 10, 1, 2)
zs = (10, 3, 8, 9, 1, 8)for zdir, x, y, z in zip(zdirs, xs, ys, zs):label = '(%d, %d, %d), dir=%s' % (x, y, z, zdir)ax.text(x, y, z, label, zdir)# Demo 2: color
ax.text(9, 0, 0, "red", color='red')# Demo 3: text2D
# Placement 0, 0 would be the bottom left, 1, 1 would be the top right.
ax.text2D(0.05, 0.95, "2D Text", transform=ax.transAxes)# Tweaking display region and labels
ax.set_xlim(0, 10)
ax.set_ylim(0, 10)
ax.set_zlim(0, 10)
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')plt.show()

在這里插入圖片描述

三維多個子圖

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d.axes3d import Axes3D, get_test_data
from matplotlib import cm
import numpy as np# set up a figure twice as wide as it is tall
# fig = plt.figure(figsize=plt.figaspect(0.5))
fig = plt.figure(figsize=(20,10))# ===============
#  First subplot
# ===============
# set up the axes for the first plot
ax = fig.add_subplot(1, 2, 1, projection='3d')# plot a 3D surface like in the example mplot3d/surface3d_demo
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X ** 2 + Y ** 2)
Z = np.sin(R)
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm,linewidth=0, antialiased=False)
ax.set_zlim(-1.01, 1.01)
fig.colorbar(surf, shrink=0.5, aspect=10)# ===============
# Second subplot
# ===============
# set up the axes for the second plot
ax = fig.add_subplot(1, 2, 2, projection='3d')# plot a 3D wireframe like in the example mplot3d/wire3d_demo
X, Y, Z = get_test_data(0.05)
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)plt.show()

在這里插入圖片描述

http://www.risenshineclean.com/news/37982.html

相關(guān)文章:

  • 南昌網(wǎng)站建設(shè)培訓(xùn)班seo優(yōu)化基礎(chǔ)教程pdf
  • qq整人網(wǎng)站怎么做百度首頁百度一下
  • 新鄉(xiāng)營銷型網(wǎng)站建設(shè)產(chǎn)品營銷推廣策略
  • 百度站長怎么做網(wǎng)站維護(hù)二級域名查詢?nèi)肟?/a>
  • 一學(xué)一做看視頻網(wǎng)站網(wǎng)站推廣的渠道有哪些
  • 做網(wǎng)站頁面該建多大的畫布以圖搜圖百度識圖
  • 做網(wǎng)站用java還是c語言專業(yè)推廣引流團(tuán)隊
  • 網(wǎng)站維護(hù)一般多久上海優(yōu)化外包
  • 法院文化建設(shè)網(wǎng)站女孩短期技能培訓(xùn)班
  • 網(wǎng)站后臺管理系統(tǒng)制作教程長春網(wǎng)站優(yōu)化哪家好
  • 營銷型網(wǎng)站制作哪家好網(wǎng)絡(luò)營銷的特點
  • 網(wǎng)站建設(shè)方案及預(yù)算百度上做優(yōu)化一年多少錢
  • 湛江網(wǎng)站的建設(shè)網(wǎng)站關(guān)鍵詞優(yōu)化推廣哪家快
  • 網(wǎng)站中的qq客服怎么做班級優(yōu)化大師是干什么用的
  • 如何推廣運營網(wǎng)站百度付費推廣
  • 網(wǎng)站建設(shè)頭部代碼網(wǎng)站描述和關(guān)鍵詞怎么寫
  • 長沙私人做網(wǎng)站現(xiàn)在推廣平臺哪家最好
  • wordpress和emlog重慶seo和網(wǎng)絡(luò)推廣
  • 網(wǎng)站開發(fā)文檔管理工具韓國網(wǎng)站
  • 淄博網(wǎng)站建設(shè)相關(guān)文章如何快速推廣
  • 天津做網(wǎng)站優(yōu)化公司上海網(wǎng)絡(luò)推廣優(yōu)化公司
  • 如何在網(wǎng)站后臺找到死鏈接群站優(yōu)化之鏈輪模式
  • 老河口做網(wǎng)站免費的外貿(mào)b2b網(wǎng)站
  • 單位網(wǎng)站建設(shè)工作功勞網(wǎng)絡(luò)營銷策劃書包括哪些內(nèi)容
  • 湖南城鄉(xiāng)建設(shè)網(wǎng)站全網(wǎng)絡(luò)品牌推廣
  • 怎么給公司建網(wǎng)站河南網(wǎng)站建設(shè)定制
  • 商城網(wǎng)站搜狗優(yōu)化排名
  • wordpress頁面的評論功能嘉興網(wǎng)站建設(shè)方案優(yōu)化
  • 有了網(wǎng)站源碼怎么做網(wǎng)站武漢百度推廣多少錢
  • 自己搭建網(wǎng)站的步驟seo搜索引擎優(yōu)化實訓(xùn)總結(jié)