- 示例图片:

- 数据准备:

- 主要模块:pandas、matplotlib、mpltern
- 模块安装
pip install pandas matplotlib mpltern
import matplotlib.pyplot as plt
import mpltern
import pandas as pd
from matplotlib.ticker import MultipleLocator
plt.rcParams['font.family'] = 'Arial Unicode MS'
plt.rcParams['font.size'] = 10
plt.rcParams["pdf.fonttype"] = 42
data = pd.read_excel('Py-data.xlsx')
fig = plt.figure(figsize=(6,4))
ax = plt.subplot(projection='ternary',ternary_sum=100.0)
pc = ax.scatter(data['Fs'], data['Wo'], data['En'],label='samples')
ax.grid()
ax.set_ternary_lim(
0, 50,
0, 100,
0, 100,
)
ax.set_tlabel("Fs")
ax.set_llabel("Wo")
ax.set_rlabel("En")
ax.taxis.set_major_locator(MultipleLocator(10))
ax.laxis.set_major_locator(MultipleLocator(10))
ax.raxis.set_major_locator(MultipleLocator(10))
ax.legend(loc=1)
plt.tight_layout()
fig.savefig('2.pdf')
plt.show()