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&

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值