Skip to content

Would be nice if SVG trees could have the tip labels rotated by 90 degrees  #26

Closed

Description

@hyanwong

At the moment, for large trees with custom labels, labels from SparseTree.draw(format="svg") are bound to overlap. An option to rotate the labels by 90 degrees would be helpful, and probably very easy to code.

Activity

  1. jeromekelleher commented on May 31, 2018

    @jeromekelleher
    Member

    The only tricky issue with this is the overall spacing. The bottom padding would need to be tweaked to allow space for the labels, which means we'd need some way to measure the size of the labels. AFAICT, this is impossible in SVG.

    Possibly the simplest option is to have a y_padding=(bottom, top) argument which can be tweaked by the user. We need something like this anyway for some labels, as they are not being rendered correctly with some font sizes, etc.

  2. hyanwong commented on May 31, 2018

    @hyanwong
    MemberAuthor

    For a rough first pass I think you could not bother accommodating label space, and simply allow users to re-frame the svg after the fact, which I know is easy in e.g. inkscape. After all, the information is all there, just not visible until you re-frame. A bit yucky, but a usable solution.

  3. hyanwong commented on May 31, 2018

    @hyanwong
    MemberAuthor

    Just to note, this requires using the transform mixin for svgwrite, http://svgwrite.readthedocs.io/en/latest/classes/mixins.html#transform-mixin. To reframe using inkscape so that everything is in the canvas, you can do inkscape --verb=FitCanvasToDrawing --verb=FileSave --verb=FileClose *.svg, but this is admittedly a hacky solution.

  4. jeromekelleher commented on May 31, 2018

    @jeromekelleher
    Member

    To reframe using inkscape so that everything is in the canvas, you can do inkscape --verb=FitCanvasToDrawing --verb=FileSave --verb=FileClose *.svg, but this is admittedly a hacky solution.

    Good to know, thanks.

  5. hyanwong commented on May 7, 2020

    @hyanwong
    MemberAuthor

    We can now do this via SVG styles (text {transform: rotate(90deg)}), and #589 would deal with the padding issue, so I'm closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions