JuliaTeX / PGFPlots.jl

This library uses the LaTeX package pgfplots to produce plots.
Other
187 stars 36 forks source link

graphplot() doesn't work with PGFPlots #77

Open sbromberger opened 7 years ago

sbromberger commented 7 years ago

Hi,

graphplot() is part of PlotRecipes.jl and allows plotting LightGraphs graphs. The function works without problems on other backends, but with PGFPlots it fails with

1mERROR: LaTeX error
Stacktrace:
 [1] save(::TikzPictures.PDF, ::TikzPictures.TikzPicture) at /Users/bromberger1/.julia/v0.6/TikzPictures/src/TikzPictures.jl:211
 [2] _show(::IOStream, ::MIME{Symbol("application/pdf")}, ::Plots.Plot{Plots.PGFPlotsBackend}) at /Users/bromberger1/.julia/v0.6/Plots/src/backends/pgfplots.jl:403
 [3] show(::IOStream, ::MIME{Symbol("application/pdf")}, ::Plots.Plot{Plots.PGFPlotsBackend}) at /Users/bromberger1/.julia/v0.6/Plots/src/output.jl:197
 [4] pdf(::Plots.Plot{Plots.PGFPlotsBackend}, ::String) at /Users/bromberger1/.julia/v0.6/Plots/src/output.jl:25
 [5] _show(::Base64EncodePipe, ::MIME{Symbol("image/png")}, ::Plots.Plot{Plots.PGFPlotsBackend}) at /Users/bromberger1/.julia/v0.6/Plots/src/output.jl:213
 [6] display(::TerminalExtensions.iTerm2.InlineDisplay, ::MIME{Symbol("image/png")}, ::Plots.Plot{Plots.PGFPlotsBackend}) at /Users/bromberger1/.julia/v0.6/TerminalExtensions/src/TerminalExtensions.jl:93
 [7] display(::TerminalExtensions.iTerm2.InlineDisplay, ::Plots.Plot{Plots.PGFPlotsBackend}) at /Users/bromberger1/.julia/v0.6/TerminalExtensions/src/TerminalExtensions.jl:103
 [8] display(::Plots.Plot{Plots.PGFPlotsBackend}) at ./multimedia.jl:194
 [9] eval(::Module, ::Any) at ./boot.jl:235
 [10] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
 [11] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
 [12] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646
 [13] (::TerminalExtensions.##3#6)(::Base.LineEdit.MIState, ::Vararg{Any,N} where N) at /Users/bromberger1/.julia/v0.6/TerminalExtensions/src/TerminalExtensions.jl:156

Any ideas on how to fix?

sbromberger commented 7 years ago

PS:

julia> versioninfo()
Julia Version 0.6.0-rc3.0
Commit ad290e93e4 (2017-06-07 11:53 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin16.5.0)
  CPU: Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, skylake)

all packages are checked out to master.

mykelk commented 7 years ago

PGFPlots.jl doesn't have the ability to plot graphs (the type with nodes and edges). Perhaps you want TikzGraphs.jl?

mykelk commented 7 years ago

Or maybe I'm not understanding how this is supposed to work? One thing that would help me debug this is to run

using TikzPictures
tikzDeleteIntermediate(false)

and then send me the .tex file that gets produced in the current directory. That line 211 in your error message indicates that lualatex is having trouble compiling the tex file.

sbromberger commented 7 years ago

I was under the impression that plotrecipes would allow graph plotting regardless of backend. Perhaps that was a bad assumption. In any case, I'll send the tex file.

sbromberger commented 7 years ago

Update: there is no .tex file generated. Here's the complete session:

phasebang:Plots$ julia6
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.0-rc3.0 (2017-06-07 11:53 UTC)
 _/ |\__'_|_|_|\__'_|  |
|__/                   |  x86_64-apple-darwin16.5.0

julia> using Plots, PlotRecipes, TikzPictures
WARNING: Method definition macroexpand(Module, Any) in module Compat at /Users/bromberger1/.julia/v0.6/Compat/src/Compat.jl:1491 overwritten in module MacroTools at /Users/bromberger1/.julia/v0.6/MacroTools/src/utils.jl:64.

julia> using LightGraphs

julia> g = Graph(3,3)
{3, 3} undirected simple Int64 graph

julia> pgfplots()
Plots.PGFPlotsBackend()

julia> tikzDeleteIntermWARNING: both LightGraphs and PlotRecipes export "center"; uses of it in module Main must be qualified
WARNING: both LightGraphs and PlotRecipes export "density"; uses of it in module Main must be qualified
julia> tikzDeleteIntermediate(false)

julia> graphplot(g)
WARNING: Array{T}(::Type{T}, m::Int) is deprecated, use Array{T}(m) instead.
Stacktrace:
 [1] depwarn(::String, ::Symbol) at ./deprecated.jl:70
 [2] Array(::Type{Int64}, ::Int64) at ./deprecated.jl:57
 [3] get_source_destiny_weight(::SparseMatrixCSC{Float64,Int64}) at /Users/bromberger1/.julia/v0.6/PlotRecipes/src/graphs.jl:39
 [4] estimate_distance(::Array{Float64,2}) at /Users/bromberger1/.julia/v0.6/PlotRecipes/src/graphs.jl:162
 [5] #by_axis_local_stress_graph#6(::Array{Float64,1}, ::Int64, ::Array{Int64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Int64, ::Array{Any,1}, ::PlotRecipes.#by_axis_local_stress_graph, ::Array{Float64,2}) at /Users/bromberger1/.julia/v0.6/PlotRecipes/src/graph_layouts.jl:101
 [6] (::PlotRecipes.#kw##by_axis_local_stress_graph)(::Array{Any,1}, ::PlotRecipes.#by_axis_local_stress_graph, ::Array{Float64,2}) at ./<missing>:0
 [7] macro expansion at /Users/bromberger1/.julia/v0.6/PlotRecipes/src/graphs.jl:268 [inlined]
 [8] apply_recipe(::Dict{Symbol,Any}, ::PlotRecipes.GraphPlot) at /Users/bromberger1/.julia/v0.6/RecipesBase/src/RecipesBase.jl:259
 [9] _process_userrecipes(::Plots.Plot{Plots.PGFPlotsBackend}, ::Dict{Symbol,Any}, ::Tuple{PlotRecipes.GraphPlot}) at /Users/bromberger1/.julia/v0.6/Plots/src/pipeline.jl:73
 [10] _plot!(::Plots.Plot{Plots.PGFPlotsBackend}, ::Dict{Symbol,Any}, ::Tuple{PlotRecipes.GraphPlot}) at /Users/bromberger1/.julia/v0.6/Plots/src/plot.jl:171
 [11] #graphplot#27(::Array{Any,1}, ::Function, ::LightGraphs.SimpleGraphs.SimpleGraph{Int64}, ::Vararg{LightGraphs.SimpleGraphs.SimpleGraph{Int64},N} where N) at /Users/bromberger1/.julia/v0.6/RecipesBase/src/RecipesBase.jl:336
 [12] graphplot(::LightGraphs.SimpleGraphs.SimpleGraph{Int64}, ::Vararg{LightGraphs.SimpleGraphs.SimpleGraph{Int64},N} where N) at /Users/bromberger1/.julia/v0.6/RecipesBase/src/RecipesBase.jl:336
 [13] eval(::Module, ::Any) at ./boot.jl:235
 [14] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
 [15] macro expansion at ./REPL.jl:97 [inlined]
 [16] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading no file, in expression starting on line 0
WARNING: Array{T}(::Type{T}, m::Int) is deprecated, use Array{T}(m) instead.
Stacktrace:
 [1] depwarn(::String, ::Symbol) at ./deprecated.jl:70
 [2] Array(::Type{Int64}, ::Int64) at ./deprecated.jl:57
 [3] get_source_destiny_weight(::SparseMatrixCSC{Float64,Int64}) at /Users/bromberger1/.julia/v0.6/PlotRecipes/src/graphs.jl:40
 [4] estimate_distance(::Array{Float64,2}) at /Users/bromberger1/.julia/v0.6/PlotRecipes/src/graphs.jl:162
 [5] #by_axis_local_stress_graph#6(::Array{Float64,1}, ::Int64, ::Array{Int64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Int64, ::Array{Any,1}, ::PlotRecipes.#by_axis_local_stress_graph, ::Array{Float64,2}) at /Users/bromberger1/.julia/v0.6/PlotRecipes/src/graph_layouts.jl:101
 [6] (::PlotRecipes.#kw##by_axis_local_stress_graph)(::Array{Any,1}, ::PlotRecipes.#by_axis_local_stress_graph, ::Array{Float64,2}) at ./<missing>:0
 [7] macro expansion at /Users/bromberger1/.julia/v0.6/PlotRecipes/src/graphs.jl:268 [inlined]
 [8] apply_recipe(::Dict{Symbol,Any}, ::PlotRecipes.GraphPlot) at /Users/bromberger1/.julia/v0.6/RecipesBase/src/RecipesBase.jl:259
 [9] _process_userrecipes(::Plots.Plot{Plots.PGFPlotsBackend}, ::Dict{Symbol,Any}, ::Tuple{PlotRecipes.GraphPlot}) at /Users/bromberger1/.julia/v0.6/Plots/src/pipeline.jl:73
 [10] _plot!(::Plots.Plot{Plots.PGFPlotsBackend}, ::Dict{Symbol,Any}, ::Tuple{PlotRecipes.GraphPlot}) at /Users/bromberger1/.julia/v0.6/Plots/src/plot.jl:171
 [11] #graphplot#27(::Array{Any,1}, ::Function, ::LightGraphs.SimpleGraphs.SimpleGraph{Int64}, ::Vararg{LightGraphs.SimpleGraphs.SimpleGraph{Int64},N} where N) at /Users/bromberger1/.julia/v0.6/RecipesBase/src/RecipesBase.jl:336
 [12] graphplot(::LightGraphs.SimpleGraphs.SimpleGraph{Int64}, ::Vararg{LightGraphs.SimpleGraphs.SimpleGraph{Int64},N} where N) at /Users/bromberger1/.julia/v0.6/RecipesBase/src/RecipesBase.jl:336
 [13] eval(::Module, ::Any) at ./boot.jl:235
 [14] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
 [15] macro expansion at ./REPL.jl:97 [inlined]
 [16] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading no file, in expression starting on line 0
WARNING: Array{T}(::Type{T}, m::Int) is deprecated, use Array{T}(m) instead.
Stacktrace:
 [1] depwarn(::String, ::Symbol) at ./deprecated.jl:70
 [2] Array(::Type{Float64}, ::Int64) at ./deprecated.jl:57
 [3] get_source_destiny_weight(::SparseMatrixCSC{Float64,Int64}) at /Users/bromberger1/.julia/v0.6/PlotRecipes/src/graphs.jl:41
 [4] estimate_distance(::Array{Float64,2}) at /Users/bromberger1/.julia/v0.6/PlotRecipes/src/graphs.jl:162
 [5] #by_axis_local_stress_graph#6(::Array{Float64,1}, ::Int64, ::Array{Int64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Int64, ::Array{Any,1}, ::PlotRecipes.#by_axis_local_stress_graph, ::Array{Float64,2}) at /Users/bromberger1/.julia/v0.6/PlotRecipes/src/graph_layouts.jl:101
 [6] (::PlotRecipes.#kw##by_axis_local_stress_graph)(::Array{Any,1}, ::PlotRecipes.#by_axis_local_stress_graph, ::Array{Float64,2}) at ./<missing>:0
 [7] macro expansion at /Users/bromberger1/.julia/v0.6/PlotRecipes/src/graphs.jl:268 [inlined]
 [8] apply_recipe(::Dict{Symbol,Any}, ::PlotRecipes.GraphPlot) at /Users/bromberger1/.julia/v0.6/RecipesBase/src/RecipesBase.jl:259
 [9] _process_userrecipes(::Plots.Plot{Plots.PGFPlotsBackend}, ::Dict{Symbol,Any}, ::Tuple{PlotRecipes.GraphPlot}) at /Users/bromberger1/.julia/v0.6/Plots/src/pipeline.jl:73
 [10] _plot!(::Plots.Plot{Plots.PGFPlotsBackend}, ::Dict{Symbol,Any}, ::Tuple{PlotRecipes.GraphPlot}) at /Users/bromberger1/.julia/v0.6/Plots/src/plot.jl:171
 [11] #graphplot#27(::Array{Any,1}, ::Function, ::LightGraphs.SimpleGraphs.SimpleGraph{Int64}, ::Vararg{LightGraphs.SimpleGraphs.SimpleGraph{Int64},N} where N) at /Users/bromberger1/.julia/v0.6/RecipesBase/src/RecipesBase.jl:336
 [12] graphplot(::LightGraphs.SimpleGraphs.SimpleGraph{Int64}, ::Vararg{LightGraphs.SimpleGraphs.SimpleGraph{Int64},N} where N) at /Users/bromberger1/.julia/v0.6/RecipesBase/src/RecipesBase.jl:336
 [13] eval(::Module, ::Any) at ./boot.jl:235
 [14] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
 [15] macro expansion at ./REPL.jl:97 [inlined]
 [16] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading no file, in expression starting on line 0
1mERROR: LaTeX error
Stacktrace:
 [1] save(::TikzPictures.PDF, ::TikzPictures.TikzPicture) at /Users/bromberger1/.julia/v0.6/TikzPictures/src/TikzPictures.jl:211
 [2] _show(::IOStream, ::MIME{Symbol("application/pdf")}, ::Plots.Plot{Plots.PGFPlotsBackend}) at /Users/bromberger1/.julia/v0.6/Plots/src/backends/pgfplots.jl:403
 [3] show(::IOStream, ::MIME{Symbol("application/pdf")}, ::Plots.Plot{Plots.PGFPlotsBackend}) at /Users/bromberger1/.julia/v0.6/Plots/src/output.jl:197
 [4] pdf(::Plots.Plot{Plots.PGFPlotsBackend}, ::String) at /Users/bromberger1/.julia/v0.6/Plots/src/output.jl:25
 [5] _show(::Base64EncodePipe, ::MIME{Symbol("image/png")}, ::Plots.Plot{Plots.PGFPlotsBackend}) at /Users/bromberger1/.julia/v0.6/Plots/src/output.jl:213
 [6] display(::TerminalExtensions.iTerm2.InlineDisplay, ::MIME{Symbol("image/png")}, ::Plots.Plot{Plots.PGFPlotsBackend}) at /Users/bromberger1/.julia/v0.6/TerminalExtensions/src/TerminalExtensions.jl:93
 [7] display(::TerminalExtensions.iTerm2.InlineDisplay, ::Plots.Plot{Plots.PGFPlotsBackend}) at /Users/bromberger1/.julia/v0.6/TerminalExtensions/src/TerminalExtensions.jl:103
 [8] display(::Plots.Plot{Plots.PGFPlotsBackend}) at ./multimedia.jl:194
 [9] eval(::Module, ::Any) at ./boot.jl:235
 [10] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
 [11] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
 [12] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646
 [13] (::TerminalExtensions.##3#6)(::Base.LineEdit.MIState, ::Vararg{Any,N} where N) at /Users/bromberger1/.julia/v0.6/TerminalExtensions/src/TerminalExtensions.jl:156

julia>
mykelk commented 7 years ago

I think I figured out the problem. See my suggested fix here: https://github.com/JuliaPlots/PlotRecipes.jl/issues/28

sbromberger commented 7 years ago

Thank you! Hopefully we can get this fixed.