You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Plotly Scatterternary三元坐标异常问题求助

Plotly土壤三元图坐标异常问题

我用Plotly制作土壤类型三元图,给特定区域的文本标注加背景框时,手动推导的坐标出现了异常:

  • 明明设置a0为0.60,实际显示却接近0.63
  • 底边的a值本该恒定不变,结果却呈下降趋势
  • 顶部a值预期是0.69,实际显示接近0.79,而且还不恒定

我用正弦定理推导b、c轴的坐标(a对应Clay(%)轴,b对应Sand(%)轴,c对应Silt(%)轴),但结果完全不符合预期。

运行环境:

  • Jupyter Notebook(IPython 7.31.1、JupyterLab 3.4.4)
  • Plotly 5.9.0
  • Windows 11

相关代码如下:

import plotly.graph_objects as go
import plotly.express as px
import pandas as pd

df = pd.DataFrame({"Clay (%)": [], "Silt (%)": [], "Sand (%)": []})
fig = go.Figure(px.scatter_ternary(df, a="Clay (%)", c="Silt (%)", b="Sand (%)"))

# Clay text_bg
a0, a1 = 0.60, 0.60      # bottom left/right vertices
da = 0.09                # change in vertical height
a2, a3 = a1+da, a0+da    # top right/left vertices
b0 = 0.26                # bottom left (eyeballed)
b1 = 0.13                # bottom right (eyeballed)
b2 = b1-da               # top right
b3 = b0-da               # top left
c0 = 0.10                # bottom left (eyeballed)
c1 = 0.24                # bottom right (eyeballed)
c2 = c1-da               # top right
c3 = c0-da               # top left
fig.add_trace(
    go.Scatterternary(a=[a0, a1, a2, a3, a0],
                      b=[b0, b1, b2, b3, b0],
                      c=[c0, c1, c2, c3, c0],
                      mode='lines',
                      line=dict(width=1.5, color='black'),
                      showlegend=False,
                      fill='toself',
                      fillcolor='rgba(1.0,1.0,1.0,0.5)')
)

fig.show()

请问这是什么原因导致的?

内容的提问来源于stack exchange,提问作者eigenVector5

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 03:24:27