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
相关产品推荐
相关产品推荐

