Compose.jl text error

I try to use compose.jl to represent a network. But I also want to write text next to it but I have an error using text.

I also tried to fix the network to make it not move at each iteration but it didn’t work.

Thanks for your help

using Plots
using GraphPlot
using LightGraphs
using Compose,Measures #Pour sauver l'image
using Printf #Pour sauver l'image
import Cairo #Pour sauver l'image Attention pas using
anim=Animation()
g = graphfamous("karate")
for i in 1:10
    p=gplot(g)
    output = compose(p,
        (context(), text(1, 1, "Julia", hcenter, vcenter), stroke("red"), fontsize(30pt)),
        (context(), rectangle(), fill("white")))
    j=length(anim.frames)+1
    tmpfilename=joinpath(anim.dir,@sprintf("%06d.png",j))
    draw(PNG(tmpfilename),output)
    push!(anim.frames, tmpfilename)
end
gif(anim, "anim_test.gif", fps = 5)

image

Hi there! I’d suggest including any using statements at the beginning of your code (since it will probably help people know which packages you’re using). People might then be able to copy/paste your code and run it to see what’s up.

Edit: that’s better…

using Plots
using GraphPlot
using LightGraphs
using Compose,Measures #Pour sauver l'image
using Printf #Pour sauver l'image
import Cairo #Pour sauver l'image Attention pas using
anim=Animation()
g = graphfamous("karate")
for i in 1:10
    p=gplot(g)
    output = compose(p,
        (context(), Compose.text(1, 1, "Julia")),
        (context(), rectangle(), fill("white")))
    j=length(anim.frames) + 1
    tmpfilename=joinpath(anim.dir,@sprintf("%06d.png",j))
    Compose.draw(PNG(tmpfilename),output)
    push!(anim.frames, tmpfilename)
end
gif(anim, "anim_test.gif", fps = 5)

So this ↑ works, but the few changes I made probably need investigating to find out what’s wrong. (Probably shouldn’t have changed more than one thing at a time… :slight_smile:)

Thanks ! Do you know how to make the network unmovable ?

I know ε about graphs, sorry. :smile: