cormullion / Karnak.jl

graph plotting and drawing networks with Julia, using Luxor graphics
https://cormullion.github.io/Karnak.jl/
MIT License
70 stars 1 forks source link

preview and save svg #25

Open kongdd opened 2 months ago

kongdd commented 2 months ago

In the following example, nothing was displayed, and no any output. Could you give some guide about how to preview and save svg?

using Karnak
using Graphs
using Colors
g = barabasi_albert(100, 1)
@drawsvg begin
    background("black")
    sethue("grey40")
    fontsize(8)
    drawgraph(g, 
        layout=stress, 
        vertexlabels = 1:nv(g),
        vertexfillcolors = 
            [RGB(rand()/2, rand()/2, rand()/2) 
               for i in 1:nv(g)]
    )
end 600 400
# Luxor drawing: (type = :svg, width = 600.0, height = 400.0, location = in memory)

image

cormullion commented 2 months ago

Hi there! You're running in a terminal, which can't display any graphical output. When you run in an environment with graphical capabilities, the SVG source returned by @drawsvg will display in a Plots window or in the notebook environment itself. The text-only representation of a Luxor drawing is Luxor drawing: (type = :svg, width = 600.0, height = 400.0, location = in memory).

Karnak is built on Luxor, so for everything except the drawgraph() function and graphing features, you should refer to the little Luxor manual. The section on Creating Drawings is probably a useful source of information.

Happy reading!