Skip to content

Returning node x,y locations in a plotted tree #2699

@hyanwong

Description

@hyanwong

For creating extra annotations on plots, it would be helpful to be able to access the x and y locations of nodes in a plotted tree. I think these are stored in node_x_coord_map and node_y_coord_map, so should be trivial to return.

One discrete way to to this would be to add an attribute (or method) to the SVGstring class that returned a dict of this data, e.g.

svg_string = ts.first().draw_svg()
positions = svg_string.positions
print(positions[node_id])  # prints tuple of (x, y)

I wonder if this is an abuse of the SVGstring class though, which is simply a subclass of the python String?

Metadata

Metadata

Assignees

No one assigned

    Labels

    VisualisationThis issue addresses visualisation

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions