Giter VIP home page Giter VIP logo

Comments (3)

hexaeder avatar hexaeder commented on June 16, 2024 1

For something more generic you could extract the paths which represent the edges. Using those you can interpolate positions along the edges as well as the tangent of the edge. That's how we determine the elabel positions and rotations internally.

This data might be useful to calculate the position where you want to place your combined label.

using GLMakie, GraphMakie, Graphs

g = complete_graph(5)
fig, ax, p = graphplot(g)

# extract list of drawn curves for the edges
edgepaths = p.plots[1][:paths][]

# calculate position and tangent vectors along those lines where t in 0..1
t = 0.2
GraphMakie.interpolate(edgepaths[1], t)
# 2-element Point{2, Float32} with indices SOneTo(2):
#  -1.1051269
#  -0.36803403

GraphMakie.tangent(edgepaths[1], t)
# 2-element Point{2, Float32} with indices SOneTo(2):
#   0.42698735
#  -0.90425766

from graphmakie.jl.

hexaeder avatar hexaeder commented on June 16, 2024

Your last question implies that you control the node positions manual anyway so I'd suggest to use Makie directly for this, i.e. use text!("foo", position=Point2(x, y)) to place the label wherever you want...

You could also set some labels to "" and move the remaining label using the elabel_shift, elabel_offset and elabel_rotation parameters.

from graphmakie.jl.

fbanning avatar fbanning commented on June 16, 2024

Thanks, I'll have a deeper look if I can make it work with the tangents solution that you offered. In the meantime I've implemented the simple heuristic I've outlined in my initial post.

from graphmakie.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.