Comments (4)
How does your code work? Checking the positions of the nodes in pixel space and changing elabels_opposite
and elabels_align
accordingly?
I am open to changes to the whole elabel
positioning business, I think there are so many options that it is pretty confusing.
from graphmakie.jl.
Yes, exactly.
First I check the angle of the position of the nodes with a function looking something like this:
function angle_between(ndpos, i, j)
x = ndpos[i]
y = ndpos[j]
θ = [ atan(d[2]/d[1]) for d in [y - x] ][] |> abs
if y[2] >= x[2] && y[1] >= x[1]
return θ |> rad2deg
elseif y[2] >= x[2] && y[1] <= x[1]
return π - θ |> rad2deg
elseif y[2] <= x[2] && y[1] <= x[1]
return π + θ |> rad2deg
elseif y[2] <= x[2] && y[1] >= x[1]
return 2π - θ |> rad2deg
end
end
(maybe there is one already available ?)
And then if angle is between 90 and 270 I consider it upside down and I add it in the elabels_opposite
p.elabels_opposite[] = [i for (i,e) in enumerate(edges(G)) if 90 < angle_between(p[:node_pos].val, e) < 270]
After I iterate through the elabels_opposite
and I toggle :top
<=> :bottom
for elabels_align
Suprisingly the update is not instant and then I have to manually trigger it by doing something trivial such as p.elabels_opposite[] = p.elabels_opposite[]
(Maybe this is actually an issue on its own that code like p.elabels_align[] = fill((:right, :bottom), length(edges(gc)))
doesn't update the graph plot.)
I think it would be nice to have it as a default behavior, because the truth is I struggled a little bit to get it working. And I am not sure that every new user will want to invest the same time.
Of course handing in a specific elabels_align
or elabels_opposite
should overwrite such a default behavior.
I am open to changes to the whole elabel positioning business, I think there are so many options that it is pretty confusing.
For the time being I wouldn't have much to suggest besides this little thingy
from graphmakie.jl.
I'd be totally on board with a new default elabels_opposite=Makie.automatic
instead of Int[]
, such that the labels will always end up in certain angle range. This could be incorporated somewhere here
I am not that sure about the right interface for the align thing. Do you think this is also necessary? It seems like the choice of the proper align is kinda arbitrary anyway because it directly depends on the node enumeration anyway... but i have not thought this through. Well it might matter for curvy edges using the new curve_distance
parameters, they tend to bent to the left and the labels should stay on the outside....
Feel free to open an issue for the update of align and opposite... this might be a problem within the text
recipe itself though, at a first glance it seems like they are properly passed down as observables...
from graphmakie.jl.
closed by #73
from graphmakie.jl.
Related Issues (20)
- curve_distance & curve_distance_usage observable not updating figure
- Precompilation stuck on Julia 1.9 HOT 6
- handle overlapping `nlabels` HOT 6
- node_color and node_marker only accept Symbol HOT 5
- Performant graph plotting and benchmarking HOT 4
- Element-wise `automatic` configuration HOT 1
- Deleting a plot doesn't remove all listeners HOT 2
- Mixing directed and undirected edges HOT 2
- Add padding around graphplot to accommodate node size. HOT 2
- `node_attr` broken using Makie v0.19.11 HOT 1
- Slow start HOT 2
- Setting node size with ilabel
- Improve Reftests HOT 1
- provide convenience function for MetaGraphsNext HOT 7
- KeyError: key :textsize not found when running doc examples HOT 2
- UndefVarError: `mouse_selection` not defined HOT 5
- arrow_shift = :end works poorly with larger edge width HOT 6
- bounding box cuts off nodes HOT 3
- `pick` one `LineSegments` returns odd index HOT 2
- Dynamic Layout + Interaction. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphmakie.jl.