如何在 Python 中创建三元等高线图?

编程入门 行业动态 更新时间:2024-10-27 00:33:05
本文介绍了如何在 Python 中创建三元等高线图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我有如下数据集(在 Python 中):

将 numpy 导入为 npA = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0, 0.1, 0.2, 0.3, 0.4, 0.2, 0.2, 0.05, 0.1])B = np.array([0.9, 0.7, 0.5, 0.3, 0.1, 0.2, 0.1, 0.15, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])C = np.array([0, 0.1, 0.2, 0.3, 0.4, 0.2, 0.2, 0.05, 0.1, 0.9, 0.7, 0.5, 0.3, 0.1, 0.2, 0.1, 0.15, 0])D = np.array([1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2])

我正在尝试使用 matplotlib 创建三元图,如图所示(.请务必查看各种链接和评论.

2019 年 9 月 11 日更新:我写了一篇关于同一主题的更近期、更实用的博客文章:x 行 Python:三元图.它使用了之前引用的 python-ternary 库.

这些似乎是 Python 的最佳选择:

Marc Harper 的 python-ternaryVeusz,一个 Python 绘图库

在另一个 SO 问题中也有一些建议:用于绘制三元/三角形图的库/工具[关闭].

I have a data set as follows (in Python):

import numpy as np
A = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0, 0.1, 0.2, 0.3, 0.4, 0.2, 0.2, 0.05, 0.1])
B = np.array([0.9, 0.7, 0.5, 0.3, 0.1, 0.2, 0.1, 0.15, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])
C = np.array([0, 0.1, 0.2, 0.3, 0.4, 0.2, 0.2, 0.05, 0.1, 0.9, 0.7, 0.5, 0.3, 0.1, 0.2, 0.1, 0.15, 0])
D = np.array([1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2])

I am trying to create ternary plots with matplotlib as shown in the figure (source). The axes are A, B, C and D values should be denoted by contours and the points need to be labelled like in figure.

Can such plots be created in matplotlib or with Python?

解决方案

Yes they can; there are at least a couple of packages to help.

I once tried to gather them all in a blog post, Ternary diagrams. Be sure to look at the various links and comments too.

Update on 2019-09-11: I wrote a more recent, and more hands-on blog post on the same subject: x lines of Python: Ternary diagrams. It uses the python-ternary library referenced before.

These seem to be the best options for Python:

Marc Harper's python-ternary Veusz, a Python plotting library

There are also some suggestions in another SO question: Library/tool for drawing ternary/triangle plots [closed].

这篇关于如何在 Python 中创建三元等高线图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-01 09:50:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/828190.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:线图   等高   如何在   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!