Getting Graphical Output from Catlab.jl

::::::::::::::
Project.toml
::::::::::::::
[deps]
Catlab = “134e5e36-593f-5add-ad60-77f754baafbe”
GATlab = “f0ffcf3b-d13a-433e-917c-cc44ccf5ead2”

can supply Manifest.toml if of interest

running snippet below

from : The Category of Graphs · Catlab.jl

using GATlab, Catlab.Theories
using Catlab.CategoricalAlgebra
using Catlab.Graphs
using Catlab.Graphics

draw(g; kw…) = to_graphviz(g; graph_attrs, node_attrs, kw…)
draw(f::ACSetTransformation; kw…) =
to_graphviz(f; node_labels=true, edge_labels=true, draw_codom=false, kw…)

to_graphviz(SchGraph)

produces output

Catlab.Graphics.Graphviz.Graph(“G”, true, “neato”, Catlab.Graphics.Graphviz.Statement[Catlab.Graphics.Graphviz.Node(“n1”, OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:label => “V”)), Catlab.Graphics.Graphviz.Node(“n2”, OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:label => “E”)), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(“n2”, “”, “”), Catlab.Graphics.Graphviz.NodeID(“n1”, “”, “”)], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:label => “src”)), Catlab.Graphics.Graphviz.Edge(Catlab.Graphics.Graphviz.NodeID[Catlab.Graphics.Graphviz.NodeID(“n2”, “”, “”), Catlab.Graphics.Graphviz.NodeID(“n1”, “”, “”)], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:label => “tgt”))], OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}(:margin => “0”, :shape => “ellipse”), OrderedCollections.OrderedDict{Symbol, Union{String, Catlab.Graphics.Graphviz.Html}}())

which looks pretty well formed …

How does one get a persistent image, say graphics format file or pdf file from the above output?

Catlab info from Manifest.toml - deps do not appear to contain graphics/plotting support
[[deps.Catlab]]
deps = [“Compose”, “DataStructures”, “GeneralizedGenerated”, “JSON”, “LightXML”, “LinearAlgebra”, “Logging”, “MLStyle”, “Pkg”, “PrettyTables”, “Random”, “Reexport”, “Requires”, “SparseArrays”, “StaticArrays”, “Statistics”, “StructEquality”, “Tables”]
git-tree-sha1 = “40552f780d19dff2bfbcad8e810fac53b28c5264”
uuid = “134e5e36-593f-5add-ad60-77f754baafbe”
version = “0.14.2”

sensible paths seem to be
add package Graphviz_jll to use Julia implemented Graphviz
or install Graphviz externally and use it’s plotting capabilities
Cairo graphics seem associated with external Graphviz
( I am mostly interested in using the Julia - Catlab environnent to
support learning about and using applied category theory. )
Thanks in advance,
Roger Smith

Welcome! May I suggest some formatting to make your post more accessible?
Three backticks are used for code blocks.

function here(is)
    some_code = is
end

By the way, almost everyone is at Julia con 2025, so an answer to your question may be delayed by a few minutes. :wink:

You need to have Graphviz installed on your system path. If you follow the standard instructions for installing graphviz on your operating system, it should work.

an idiom that does the trick, with the Graphviz Bin in the system path

open(“t1.pdf”,“w”) do f
write(f, Catlab.Graphics.Graphviz.run_graphviz( to_graphviz(SchGraph); format=“pdf” ) )
end

thanks,
roger