Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotation of labels when the angle is between 90° and 270° #17

Open
PhilippeMeyer68 opened this issue Jun 16, 2024 · 1 comment
Open

Comments

@PhilippeMeyer68
Copy link

PhilippeMeyer68 commented Jun 16, 2024

Currently the labels are following the circle and become difficult to read on the left side of the dendrogram.
Is it possible to add an argument to revert them when the angle is between 90° and 270° such as in the left part of the following picture

circular_dendrogram

Thank you very much,

@PhilippeMeyer68
Copy link
Author

PhilippeMeyer68 commented Jun 16, 2024

Actually this is not difficult to do, you just have to change the lines of code 185-200 by:

    if addlabels == True:
        assert len(Z2["ivl"]) == len(label_coords), (
            f'Internal error, label numbers for Z2 ({len(Z2["ivl"])})'
            f" and for calculated labels ({len(label_coords)}) must be equal!"
        )
        for (_x, _y, _rot), label in zip(label_coords, Z2["ivl"]):
            if _rot > 90 and _rot < 270 :
                _rot = _rot + 180
                ha = "right"
            else:
                ha = "left"
            ax.text(
                _x,
                _y,
                label,
                {"va": "center"},
                rotation_mode="anchor",
                rotation=_rot,
                fontsize=fontsize,
                ha=ha,
            )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant