Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with GraphRecipes.graphplot #325

Closed
Holbormon opened this issue Feb 22, 2024 · 5 comments
Closed

Incompatibility with GraphRecipes.graphplot #325

Holbormon opened this issue Feb 22, 2024 · 5 comments

Comments

@Holbormon
Copy link

Consider the following MRE:

using GraphRecipes
using Plots; pgfplotsx()

A = rand((0, 1), 10, 10)
g = graphplot(A, markershape = :circle, curves = false)

This yields the following LuaLaTeX error:

! Package pgfkeys Error: I do not know the key '/tikz/num edges nodes', to whic
h you passed '{58}{10}', and I am going to ignore it. Perhaps you misspelled it.
See the pgfkeys package documentation for explanation.
Type  H <return>  for immediate help.
...               
l.44 table[row sep={\\}]

Which in turn causes the following Julia stacktrace:

Error showing value of type Plots.Plot{Plots.PGFPlotsXBackend}:
ERROR: The latex command `lualatex jl_hEhuPu78DG.tex` failed
Stacktrace:
  [1] savepdf(filename::String, td::PGFPlotsX.TikzDocument; latex_engine::PGFPlotsX.LaTeXEngine, buildflags::Vector{…}, run_count::Int64, tmp::String)
    @ PGFPlotsX ~/.julia/packages/PGFPlotsX/4g8BA/src/tikzdocument.jl:202
  [2] savepdf
    @ ~/.julia/packages/PGFPlotsX/4g8BA/src/tikzdocument.jl:159 [inlined]
  [3] save(filename::String, td::PGFPlotsX.TikzDocument; include_preamble::Bool, latex_engine::PGFPlotsX.LaTeXEngine, buildflags::Vector{…}, dpi::Int64, showing_ide::Bool)
    @ PGFPlotsX ~/.julia/packages/PGFPlotsX/4g8BA/src/tikzdocument.jl:86
  [4] save(filename::String, td::PGFPlotsX.TikzDocument)
    @ PGFPlotsX ~/.julia/packages/PGFPlotsX/4g8BA/src/tikzdocument.jl:67
  [5] display(d::PGFPlotsX.PGFPlotsXDisplay, p::PGFPlotsX.TikzDocument)
    @ PGFPlotsX ~/.julia/packages/PGFPlotsX/4g8BA/src/tikzdocument.jl:355
  [6] _display(plt::Plots.Plot{Plots.PGFPlotsXBackend})
    @ Plots ~/.julia/packages/Plots/HyyIK/src/backends/pgfplotsx.jl:1386
  [7] display(::Plots.PlotsDisplay, plt::Plots.Plot{Plots.PGFPlotsXBackend})
    @ Plots ~/.julia/packages/Plots/HyyIK/src/output.jl:169
  [8] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:340
  [9] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
 [10] invokelatest
    @ ./essentials.jl:889 [inlined]
 [11] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL /usr/share/julia/stdlib/v1.10/REPL/src/REPL.jl:315
 [12] (::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL /usr/share/julia/stdlib/v1.10/REPL/src/REPL.jl:284
 [13] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL /usr/share/julia/stdlib/v1.10/REPL/src/REPL.jl:569
 [14] (::REPL.var"#do_respond#80"{…})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL /usr/share/julia/stdlib/v1.10/REPL/src/REPL.jl:911

I have managed to extract the generated temporary .tex file and did some debugging of my own. As it turns out, PGFPlotsX is generating a lot of the following tex command:

\addplot[color={rgb,1:red,0.0;green,0.0;blue,0.0}, name path={some-hex}, forget plot, draw opacity={1.0}, line width={1}, solid, num edges nodes={58}{10}]

in which num edges nodes={}{} is not recognized as valid key by PGF. Unfortunately, I do not have the required PGF/tikz knowledge to know whether it's because of a missing \usepackage, \usepgfplotslibrary,\usetikzlibrary or because of a deeper bug.

I have, however, noticed that for small graphs (producing < 100 errors), the temporary .tex file compiles just fine by using the -interaction=nonstopmode argument of lualatex, as it ignores the errors and manages to produce a pdf regardless. I believe the 100 errors threshold is hardcoded in TeX.

@KristofferC
Copy link
Owner

This seems to be a Plots.jl issue or?

@Holbormon
Copy link
Author

Stacktrace points at PGFPlotsX/src/tikzdocument.jl, and the error has to do with the .tex generated figure. Unless Plots.jl is doing anything which messes with the code generated by the PGFPlotsX backend, this looks like a PGFPlotsX issue.

@KristofferC
Copy link
Owner

KristofferC commented Feb 22, 2024

Could you provide an example without Plots.jl then that shows the bug in this package? Where does num edges nodes come from?

@Holbormon
Copy link
Author

Upon closer inspection of the TikzDocument object wrapped by Plots.jl, it would seem that num edges nodes is being added as an Option to the TikzPicture object by some upstream piece of code, as you correctly surmised earlier.

A surface guess would point at GraphRecipes.jl as being the introducer of this variable, but I don't have a good enough grasp of the whole ecosystem to tell which package down the GraphRecipes.jl => Plots.jl => PGFPlotsX.jl chain should be responsible for stopping it from ending up in the final .tex code.

I'm fine with opening an issue under either or both of these other two packages but I could definitely use a hint regarding which one to target.

@Holbormon
Copy link
Author

Holbormon commented May 16, 2024

A fix was applied and merged upstream. Thank you for helping kickstart the discussion !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants