问题描述
限时送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-ternary
Veusz,一个 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'spython-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:关键词]
发布评论