get (X, Y) coordinates of a node in sankey plot
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 功能
- 描述清晰度
- 需要釐清
- 活躍度
- 冷清
- 技術堆疊
- python
研究方向
未指定檔案、測試或進入點。首先在 plotly.py 的原始碼和文件中追蹤 Sankey 節點位置的處理方式,然後確定是否可以指定受支援的座標存取器或精確的轉換行為;當所要求的座標或文件化的限制已確立,且包含對拖曳節點的涵蓋時,即視為完成。
由索引模型根據 Issue 內容生成。
描述
Problem definition
I wrote an application that loads properties of a sankey plot from a file and displays it. I'd like to be able to manually (drag and drop) arrange node positions and then save their (X, Y) coordinates to a file to be able to continue the work later. For that I would need to get access to (X, Y) coordinates of nodes but I haven't found anything about that in the documentation and the source code.
Applied workaround
My current workaround is to read HTML source of generated plot and estimate (X, Y) coordinates based on parameters of translate functions defined for each node. However, this approach is inaccurate. Here's simplified code describing a single node:
<g class="sankey-node" transform="translate(13.260000228881836,401.4360046386719)">
<rect class="node-rect" height="185.32853214031275" width="20.000000000000004">
</rect>
...
</g>
The above node, in a python code, has X coordinate set to: 0.01 and Y coordinate set to 0.45. My current formulas to estimate python coordinates (X*, Y*) based on SVG translations (X, Y) are:
X* = (X - (node_width / 2)) / (plot_width - (margin_left + margin_right) - (padding_left + padding_right))
Y* = (Y - (node_height / 2)) / (plot_height - (margin_top + margin_bottom) - (padding_top + padding_bottom)) + node_height * 0.0009
Referring to the pasted SVG code and corresponding python coordinates the formulas would do the following:
X -> X* : 13.260000228881836 -> 0.01
Y -> Y* : 401.4360046386719 -> 0.45
I wrote that the above formulas are inaccurate because they:
[1] Reproduce python (X, Y) with some error.
[2] The error is affected by a plot size but it's not clear to me what is the relation. The error decreases with increasing plot size. When the plot is maximized on a 2560x1440 screen I get error less then 0.01 which is acceptable.
[3] In case of Y coordinate I had to add the node_height * 0.0009 component because the higher the node was the bigger the error was. I don't know where this number comes from but without it errors for high nodes were significantly bigger.
Questions
[1] Is there a better way read python (X, Y) coordinates of nodes?
[2] If there is no way to do it better could you tell if you plan to add a feature that would allow to access (X, Y) coordinates of nodes?
[3] Could you tell what are formulas used to transfrom python (X, Y) coordinates to parameters in the translate function used in the SVG code of a generated plot?
- 主要語言
- Python
- 星號
- 18.8k
- 分支
- 2.8k
- 平均合併
- 13 小時 28 分鐘
- 30 天內合併 PR
- 20
環境準備
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
plotly/plotly.py 的其他 Issue
-
P3 size: 1 task
難度 2/5 1-3 小時 新手友好度 65/100
plotly/plotly.py#5769 · 1 個 reaction ·
維護者通常 1 天內回覆
-
P3 size: 1 task
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
bug P1
難度 1/5 1 小時以內 新手友好度 68/100
維護者通常 1 天內回覆
-
feature P3
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆
-
feature P3
難度 2/5 1-3 小時 新手友好度 72/100
plotly/plotly.py#3859 · 1 則留言 ·
維護者通常 1 天內回覆
相似的 Issue
-
good first issue
難度 2/5 1-3 小時 新手友好度 88/100
-
難度 2/5 1-3 小時 新手友好度 88/100
vllm-project/vllm-metal#822 ·
維護者通常 1 天內回覆
-
vector-store
難度 1/5 1-3 小時 新手友好度 90/100
維護者通常 1 天內回覆
-
[Bug]: chunk_span_bounds and _validated_chunk_spans reject Pydantic models ChunkSpan and AudioFile未關閉
難度 2/5 1-3 小時 新手友好度 78/100
BasedHardware/omi#19047 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆