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

handle overlapping nlabels #131

Open
SimonEnsemble opened this issue May 9, 2023 · 6 comments
Open

handle overlapping nlabels #131

SimonEnsemble opened this issue May 9, 2023 · 6 comments

Comments

@SimonEnsemble
Copy link

[feature request]

I have a graph with many nodes. can't show all node labels with nlabels without some ugly overlap.

but Gadfly does it nicely with their Geom.label. would be awesome if GraphMakie.jl could do this. their code for this is here. showing GraphMakie vs Gadfly below.

Screenshot 2023-05-09 at 9 31 29 AM Screenshot 2023-05-09 at 9 31 18 AM
@hdavid16
Copy link
Collaborator

hdavid16 commented May 9, 2023

The layouts are very different. How are you setting the node x-y coordinates in Gadfly?

Also, I don't see node K2HPO4 in your bottom plot.

@asinghvi17
Copy link
Member

This would probably also involve an improvement on Makie's end. I tried to implement a text_repel! recipe in Makie from some R code, but having the Julia code from https://github.com/GiovineItalia/Gadfly.jl/blob/master/src/geom/label.jl helps quite a bit. Will see if I can do something about it, but if anyone is interested it would be a pretty useful feature!

@SimonEnsemble
Copy link
Author

oh, I pre-computed the layout from NetworkLayout, then manually scaled the coords of the blue points, to draw this in Gadfly. I am just screen-shotting part of the visualization. (didn't want to put pictures of my unpublished research online haha).

@asinghvi17 yes, would be very useful for Makie in general, when labeling points of a scatter plot! we need this for a scatter plot on another project (text! would lead to crazy-overlapping labels yet we want to label as many as possible.).

if only the text were spheres; then NetworkLayout could be used to repel the text away from each other and the scatter plot points.

@hdavid16
Copy link
Collaborator

hdavid16 commented May 9, 2023

I'd expect you would not get as ugly of an overlap if the nodes were distributed as in your gadfly plot.

@hexaeder
Copy link
Collaborator

This would probably also involve an improvement on Makie's end.

You mean a new alignment option text recipe, such that text(positions; text=[...], align=:dynamic) would choose an appropriate anchor for each textbox with little overlap? How'd one handle the zoom level? Normally, text happens in pixelspace while the positions happen to be in markerspace...

@asinghvi17
Copy link
Member

Yep, something like that. Text is laid out in screen space in any case, so it's not too difficult to do. In terms of zoom level - we would have to recompute whenever axis limits change.

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

4 participants