Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

get (X, Y) coordinates of a node in sankey plot

Ouverte
#4,799 2 commentaires 2 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
35/100
Type d'issue
Fonctionnalité
Clarté
À clarifier
Activité
Calme
Stack technique
python

Piste de recherche

Aucun fichier, test ou point d’entrée n’est nommé. Commencez par suivre la gestion de la position des nœuds Sankey dans le code source et la documentation de plotly.py, puis déterminez s’il est possible de spécifier un accesseur de coordonnées pris en charge ou un comportement de conversion précis ; le travail est terminé lorsque les coordonnées demandées ou la limitation documentée sont établies avec une couverture pour les nœuds déplacés par glisser-déposer.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

feature P3

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?

Langage dominant
Python
Étoiles
18.8k
Forks
2.8k
Merge moyen
13 h 41 min
PR mergées (30 j)
21

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de plotly/plotly.py

Toutes les issues de plotly/plotly.py

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.