python - 如何使用 Python Plotly 制作三元等高线图?

标签 python plotly

我正在尝试绘制在单纯形上定义的函数。显然,你可以 do it very nicely using the Matlab API .

enter image description here

但我不知道如何使用 Python API 执行此操作。该引用有一个名为 Ternary Contour Plots in Python 的部分但它不绘制数值函数,而是将单纯形映射到给定离散集的函数。

我尝试模拟 Matlab 代码:

import plotly as py

A = [0, .2, .2, .2, 0, .6, .75, .9, 0, 1, .8, .3]
B = [1, .2, .4, .1, 0, .4, .05, 0, .8, 0, .05, .3]
C = [0, .6, .4, .7, 1, 0, .2, .1, .2, 0, .15, .4]
Z = [.1, .5, .1, .2, 1, .8, .4, 0, .1, .6, 1, .7]

trace = {
    "type": 'scatterternary',
    "carpet": 'scattercontour',
    "a": A,
    "b": B,
    "c": C,
    "z": Z
}

layout = {
    'title': 'Simple Ternary Contour Plot with Python'
}

figure = dict(data=[trace], layout=layout)
py.offline.plot(figure, validate=False)

但我得到的是这个 plotly :

enter image description here

最佳答案

如果还有人感兴趣,here是一个 Jupyter Notebook,用于查看如何生成 Plotly 三元等高线图。

关于python - 如何使用 Python Plotly 制作三元等高线图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51104595/

相关文章:

python - 如何从工作线程导入 Python 异步模块?

Python:如何在笔记本中可视化绘图

html - R:将多个 html 小部件保存在一起

python - 将直方图从 matplotlib 导入到plotly

python - Plotly Geoscatter 与聚合 : show aggregation in hover Info

python - 包装一个函数隐藏它的属性?

python - 如何从 python 中的 @staticmethod 函数中找出我被调用的类?

python - 使用 Pandas 处理 CSV 文件中的字符串值列

python - 在哪里可以找到Python中列表理解的形式语法?

javascript - 处理后从plotly select中清除event_data