python - 在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
解决方案
推荐阅读
- google-chrome - 如何在新选项卡上保留日志
- laravel-5 - Vue组件中的Laravel注销路由
- r - R:使用 MatchIt 进行倾向得分匹配。如何为不同的协变量指定所需的匹配精度?
- react-native - React Native 底部模态与水平滚动
- python - Python 请求:断言 status_code 没有失败
- javascript - 保留有太多 div 的网页的一部分,已修复
- matlab - 如何覆盖矩阵中的特定值?MATLAB
- react-native - 移动选项卡应重置堆栈以响应本机路由器通量
- excel - Excel - 如何自动将文本 URL 转换为活动超链接?
- wordpress - 如何在 WordPress 插件设置中添加切换按钮?