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

歡迎訪問 生活随笔!

生活随笔

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

python

python金字塔图绘制_如何用R或Python绘制3d(4变量)三元(金字塔)图?

發布時間:2025/3/15 python 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python金字塔图绘制_如何用R或Python绘制3d(4变量)三元(金字塔)图? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

嗯,我自己用了wikipedia article、SO post和一些蠻力解決了這個問題。對不起,代碼墻,但你必須畫出所有的繪圖輪廓和標簽等等。在import numpy as np

import matplotlib.pyplot as plt

from mpl_toolkits.mplot3d import axes3d, Axes3D

from itertools import combinations

import pandas as pd

def plot_ax(): #plot tetrahedral outline

verts=[[0,0,0],

[1,0,0],

[0.5,np.sqrt(3)/2,0],

[0.5,0.28867513, 0.81649658]]

lines=combinations(verts,2)

for x in lines:

line=np.transpose(np.array(x))

ax.plot3D(line[0],line[1],line[2],c='0')

def label_points(): #create labels of each vertices of the simplex

a=(np.array([1,0,0,0])) # Barycentric coordinates of vertices (A or c1)

b=(np.array([0,1,0,0])) # Barycentric coordinates of vertices (B or c2)

c=(np.array([0,0,1,0])) # Barycentric coordinates of vertices (C or c3)

d=(np.array([0,0,0,1])) # Barycentric coordinates of vertices (D or c3)

labels=['a','b','c','d']

cartesian_points=get_cartesian_array_from_barycentric([a,b,c,d])

for point,label in zip(cartesian_points,labels):

if 'a' in label:

ax.text(point[0],point[1]-0.075,point[2], label, size=16)

elif 'b' in label:

ax.text(point[0]+0.02,point[1]-0.02,point[2], label, size=16)

else:

ax.text(point[0],point[1],point[2], label, size=16)

def get_cartesian_array_from_barycentric(b): #tranform from "barycentric" composition space to cartesian coordinates

verts=[[0,0,0],

[1,0,0],

[0.5,np.sqrt(3)/2,0],

[0.5,0.28867513, 0.81649658]]

#create transformation array vis https://en.wikipedia.org/wiki/Barycentric_coordinate_system

t = np.transpose(np.array(verts))

t_array=np.array([t.dot(x) for x in b]) #apply transform to all points

return t_array

def plot_3d_tern(df,c='1'): #use function "get_cartesian_array_from_barycentric" to plot the scatter points

#args are b=dataframe to plot and c=scatter point color

bary_arr=df.values

cartesian_points=get_cartesian_array_from_barycentric(bary_arr)

ax.scatter(cartesian_points[:,0],cartesian_points[:,1],cartesian_points[:,2],c=c)

#Create Dataset 1

np.random.seed(123)

c1=np.random.normal(8,2.5,20)

c2=np.random.normal(8,2.5,20)

c3=np.random.normal(8,2.5,20)

c4=[100-x for x in c1+c2+c3] #make sur ecomponents sum to 100

#df unecessary but that is the format of my real data

df1=pd.DataFrame(data=[c1,c2,c3,c4],index=['c1','c2','c3','c4']).T

df1=df1/100

#Create Dataset 2

np.random.seed(1234)

c1=np.random.normal(16,2.5,20)

c2=np.random.normal(16,2.5,20)

c3=np.random.normal(16,2.5,20)

c4=[100-x for x in c1+c2+c3]

df2=pd.DataFrame(data=[c1,c2,c3,c4],index=['c1','c2','c3','c4']).T

df2=df2/100

#Create Dataset 3

np.random.seed(12345)

c1=np.random.normal(25,2.5,20)

c2=np.random.normal(25,2.5,20)

c3=np.random.normal(25,2.5,20)

c4=[100-x for x in c1+c2+c3]

df3=pd.DataFrame(data=[c1,c2,c3,c4],index=['c1','c2','c3','c4']).T

df3=df3/100

fig = plt.figure()

ax = Axes3D(fig) #Create a 3D plot in most recent version of matplot

plot_ax() #call function to draw tetrahedral outline

label_points() #label the vertices

plot_3d_tern(df1,'b') #call function to plot df1

plot_3d_tern(df2,'r') #...plot df2

plot_3d_tern(df3,'g') #...

總結

以上是生活随笔為你收集整理的python金字塔图绘制_如何用R或Python绘制3d(4变量)三元(金字塔)图?的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: wwwxxx亚洲| 国产女人叫床高潮大片免费 | 中文字幕在线观看高清 | 黄色av小说在线观看 | 欧美成人综合色 | www.超碰在线.com | 69xx网站| 久久国产亚洲精品无码 | 美女草逼视频 | 黄色草逼网站 | 香蕉伊思人视频 | av网站免费观看 | 色女人av | 蜜桃视频久久一区免费观看入口 | 在线观看日韩av | 久草观看视频 | 青青草原成人网 | 成人在线观看a | 国产精品久久久久久久成人午夜 | av黄色在线免费观看 | 亚洲美女中文字幕 | 久操视频免费在线观看 | 午夜精品电影 | 奇米四色网 | 国产精品久久久久三级无码 | 国产99久久久国产精品成人免费 | 亚洲香蕉视频 | 大陆日韩欧美 | 亚洲短视频| 夜夜摸夜夜爽 | 美女精品在线 | 天天天天干 | 日日做夜夜爽毛片麻豆 | 公侵犯人妻中文字慕一区二区 | 久热精品免费视频 | 97se在线| 成人app在线 | 精品毛片在线观看 | 深夜福利av | 最近日韩中文字幕中文 | 好男人影视www | 香蕉视频黄色片 | 一区二区三区四区在线播放 | 欧美综合另类 | 三级特黄| 91精品国产麻豆国产自产在线 | 美女人人操 | 久久国产精品一区 | 国产黄色成人 | 伊人日日夜夜 | 色综合av| 亚洲av无码成人精品区 | 日韩成人动漫在线观看 | 小小姑娘电影大全免费播放 | 四色成人 | 18禁一区二区三区 | 久久人人爽人人爽人人 | 中文字幕在线播放第一页 | 奇米精品一区二区三区在线观看 | 色午夜| 中文字幕.com | av男人的天堂在线观看 | 久一区二区三区 | 66av欧美 | 国产乱子伦精品无码专区 | 国产femdom调教7777 | 欧美情侣性视频 | 一级福利视频 | 久久精品国产亚洲av成人 | 非洲黑人狂躁日本妞 | 久久手机看片 | 欧美日韩激情视频在线观看 | 在线观看欧美一区二区三区 | 最好看的日本字幕mv视频大全 | 日日噜噜噜噜人人爽亚洲精品 | 夜夜爽夜夜操 | 国产freexxxx性播放麻豆 | 婷婷中文网| 精品一区二区久久久久久按摩 | av中文字幕亚洲 | 操操av| 五月天视频网 | 亚洲自拍偷拍一区二区 | 人体写真 福利视频 | 亚洲色图15p| 欧美激情片在线观看 | 中国少妇色 | 国产男男gay体育生网站 | 亚洲va视频| 99碰碰| 天堂√ | 亚洲免费视频一区二区 | 亚洲欧美日韩电影 | 欧美日韩经典 | 欧美激情爱爱 | 91亚洲国产成人精品一区 | 日韩欧美中 | 亚洲av无码精品色午夜果冻不卡 | 色臀|