有没有办法使用 python 三元包在三元图中旋转刻度标签?

Is there a way to rotate the ticklabels in a ternary plot with the python ternary package?

我正在使用 python 三元 package。为了提高对绘图的直观理解,我想旋转轴上的刻度标签以指示该轴的网格线指向哪个方向,如下图所示。

Python-三进制使用以下代码生成此结果

from matplotlib import pyplot as plt
import ternary

figure, ax = plt.subplots(figsize=(6, 6))
tax = ternary.TernaryAxesSubplot(ax=ax, scale=100)

# draw Boundary and Gridlines
tax.boundary(linewidth=2.0)
tax.gridlines(color="black", multiple=10)

# ticks settings
tax.ticks(
    axis='lbr',
    linewidth=1,
    multiple=20,
    offset=0.02,
    fontsize=12
)

# remove mpl axes
tax.get_axes().axis('off')
tax.clear_matplotlib_ticks()
ternary.plt.show() 

到目前为止我尝试过的是

没有成功。感谢您的帮助!

廉价的解决方案当然是将刻度标签作为注释,可以使用 rotation 参数进行旋转。不是很优雅,但暂时解决了问题

from matplotlib import pyplot as plt
import ternary

fs = 16

figure, ax = plt.subplots(figsize=(6, 6))
tax = ternary.TernaryAxesSubplot(ax=ax, scale=100)

# draw Boundary and Gridlines
tax.boundary(linewidth=2.0)
tax.gridlines(color="black", multiple=10)

# define tick locations
tick_locs = range(10, 100, 10)

# add left ticks 
for i in tick_locs:
    tax.annotate(
        text=str(i),
        position=[-10, 100-i +2, 90],
        rotation=300,
        fontsize=fs
    )
    # add tick lines
    tax.line(
        [-3 , i+3, 90],
        [0 , i, 90],
        color='k'
    )
    
# add bottom ticks 
for i in tick_locs:
    tax.annotate(
        text=str(i),
        position=[i - 2, -10, 90],
        rotation=60,
        fontsize=fs
    )
    # add tick lines
    tax.line(
        [i , -3, 90],
        [i , 0, 90],
        color='k'
    )

# add right ticks
for i in tick_locs:
    tax.annotate(
        text=str(i),
        position=[105-i, i-2, 0],
        rotation=0,
        fontsize=fs
    )
    # add tick lines
    tax.line(
        [100-i , i, 0],
        [103-i , i, 0],
        color='k'
    )

# remove mpl axes
tax.clear_matplotlib_ticks()
ternary.plt.show()