首页 > 解决方案 > 在python中绘制三个自变量的三元轮廓

问题描述

我想使用 python 绘制 3 个自变量的三元轮廓。我有一个包含两种脂质(DIPC 和 DPPC)和胆固醇的膜蛋白系统。数据文件包含在不同时刻存在于膜蛋白表面的这些分子的数量。数据文件的大小为 [10001 X 3]。

以下是代码:

import plotly.figure_factory as ff
import numpy as np
 
file_data  = np.loadtxt("MSM-original-data-S1.dat",dtype=int)
file_data1 = np.loadtxt("normalized-MSM-data-system-1.dat",dtype=float)
A=np.array(file_data)
B=np.array(file_data1)

CHOL = A[:,0]
DIPC = A[:,1]
DPPC = A[:,2]

norm_chol = B[:,0]

fig = ff.create_ternary_contour(np.array([CHOL, DIPC, DPPC]), norm_chol, pole_labels=['Al', 'Y', 'Cu'],                                interp_mode='cartesian')

fig.show()

以下是我得到的错误: Traceback(最近一次调用最后一次):文件“code1.py”,第 31 行,in fig = ff.create_ternary_contour(np.array([CHOL, DIPC, DPPC]), norm_chol, File “/home/tuo83323/.local/lib/python3.8/site-packages/plotly/figure_factory/_ternary_contour.py”,第 631 行,在 create_ternary_contour 坐标 = _prepare_barycentric_coord(坐标)文件“/home/tuo83323/.local/lib /python3.8/site-packages/plotly/figure_factory/_ternary_contour.py",第 177 行,在 _prepare_barycentric_coord 中引发 ValueError(msg) ValueError:所有数据点的坐标总和应为 1 或 100

Following are the first few lines of my input file (normalized-MSM-data-system-1.dat): 0.028169 0.357981 0.0193133 0.0234742 0.352113 0.0214592 0.0234742 0.359155 0.0246781 0.028169 0.362676 0.0225322 0.0234742 0.350939 0.0236052

标签: pythoncontourternary

解决方案


推荐阅读