日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

【Python】3D Axis

發布時間:2025/4/5 python 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Python】3D Axis 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
# -*- coding:utf-8 -*-import numpy as np import matplotlib.pyplot as plt import mpl_toolkits.mplot3d.axes3d as p3 import matplotlib.animation as animation# Fixing random state for reproducibility np.random.seed(19680801)''' # 函數名稱:Gen_RandLine # 函數功能:產生隨機線條 # 參數:length:線段的樹目 # dims:數據的維數 # 返回值: ''' def Gen_RandLine(length, dims=2):"""Create a line using a random walk algorithmlength is the number of points for the line.dims is the number of dimensions the line has."""lineData = np.empty((dims, length))lineData[:, 0] = np.random.rand(dims)for index in range(1, length):# scaling the random numbers by 0.1 so# movement is small compared to position.# subtraction by 0.5 is to change the range to [-0.5, 0.5]# to allow a line to move backwards.step = ((np.random.rand(dims) - 0.5) * 0.1)lineData[:, index] = lineData[:, index - 1] + stepreturn lineDatadef update_lines(num, dataLines, lines):for line, data in zip(lines, dataLines):# NOTE: there is no .set_data() for 3 dim data...line.set_data(data[0:2, :num])line.set_3d_properties(data[2, :num])return lines# Attaching 3D axis to the figure Ax = [0, 8] Ay = [0, 7] Az = [0, 6] Bx = [0, 6] By = [0, 7] Bz = [0, 8]fig = plt.figure() ax = p3.Axes3D(fig)# 繪制三維直線 ax.plot(Ax, Ay, Az, color='red', linestyle='-') # 繪制三維箭頭 ax.quiver(Ax[-1], Ay[-1], Az[-1], Ax[-1]*0.1, Ay[-1]*0.1, Az[-1]* 0.1, color='red', linestyle='-', normalize=False) # 繪制三維點 ax.scatter(Ax[-1]*1.1, Ay[-1]*1.1, Az[-1]*1.1, color='red') # 添加三維文字注釋 ax.text(Ax[-1]+1, Ay[-1]-1, Az[-1]-0, "Qb = [Qx', Qy', Qz']", color='black') ax.text(Ax[-1]+1, Ay[-1]+1, Az[-1]+1, "Point_B", color='black') ax.scatter(0, 0, 0, color='red') ax.text(0, 0, 1, "Point_A", color='black') ax.text(0+2, 0-1, 1-0, "Qa = [Qx, Qy, Qz]", color='black')''' ax.plot(Bx, By, Bz, color='blue', linestyle='-.') ax.quiver(Bx[-1], By[-1], Bz[-1], Bx[-1]*0.1, By[-1]*0.1, Bz[-1]* 0.1, color='blue', linestyle='-.', normalize=False) ax.scatter(Bx[-1]*1.1, By[-1]*1.1, Bz[-1]*1.1, color='blue') ax.text(Bx[-1]-1, By[-1]-1, Bz[-1]+1, "Qb = [Qx', Qy', Qz']", color='black') ax.text(Bx[-1]+1, By[-1]+1, Bz[-1]+1, "Point_B", color='black') '''ax.text2D(0.05, 0.95, "3D Axis", transform=ax.transAxes)# Setting the axes properties ax.set_xlim3d([-1, 10]) ax.set_xlabel('XAxis') ax.set_ylim3d([-1, 10]) ax.set_ylabel('YAxis') ax.set_zlim3d([-1, 10]) ax.set_zlabel('ZAxis') # ax.set_title('Change the title')plt.show()

總結

以上是生活随笔為你收集整理的【Python】3D Axis的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。