GraphRecipes.jl
GraphRecipes.jl copied to clipboard
Graph example not working
I just tried the first example on the main page concerning graphs (spectral) and that does not seem to work. I am using julia v 0.6.1 together with PlotRecipes 0.3.0 and the pyplot backend (using python3).
julia> @time using PlotRecipes
104.516603 seconds (20.16 M allocations: 1.319 GiB, 0.86% gc time)
julia> Plots.backend()
Plots.GRBackend()
julia> @time pyplot()
17.392845 seconds (2.38 M allocations: 134.907 MiB, 0.51% gc time)
Plots.PyPlotBackend()
julia> n = 15
A = Float64[(rand()<0.5 ? 0 : rand()) for i=1:n,j=1:n]
for i=1:n
A[i,1:i-1] = A[1:i-1,i]
end
node_weights = 1:n
[...]
julia>
graphplot(A,
node_weights = 1:n,
marker = (:heat, :rect),
line = (3, 0.5, :blues),
marker_z = 1:n,
names = 1:n
)
julia> WARNING: Array(::Type{T}, m::Int) where T 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(::Array{Float64,2}) at /home/yves/.julia/v0.6/PlotRecipes/src/graphs.jl:43
[4] macro expansion at /home/yves/.julia/v0.6/PlotRecipes/src/graphs.jl:247 [inlined]
[5] apply_recipe(::Dict{Symbol,Any}, ::PlotRecipes.GraphPlot) at /home/yves/.julia/v0.6/RecipesBase/src/RecipesBase.jl:287
[6] _process_userrecipes(::Plots.Plot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}, ::Tuple{PlotRecipes.GraphPlot}) at /home/yves/.julia/v0.6/Plots/src/pipeline.jl:81
[7] _plot!(::Plots.Plot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}, ::Tuple{PlotRecipes.GraphPlot}) at /home/yves/.julia/v0.6/Plots/src/plot.jl:175
[8] (::RecipesBase.#kw##plot)(::Array{Any,1}, ::RecipesBase.#plot, ::PlotRecipes.GraphPlot) at ./<missing>:0
[9] #graphplot#29(::Array{Any,1}, ::Function, ::Array{Float64,2}, ::Vararg{Array{Float64,2},N} where N) at /home/yves/.julia/v0.6/RecipesBase/src/RecipesBase.jl:363
[10] (::PlotRecipes.#kw##graphplot)(::Array{Any,1}, ::PlotRecipes.#graphplot, ::Array{Float64,2}, ::Vararg{Array{Float64,2},N} where N) at ./<missing>:0
[11] eval(::Module, ::Any) at ./boot.jl:235
[12] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
[13] macro expansion at ./REPL.jl:97 [inlined]
[14] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading no file, in expression starting on line 0
WARNING: Array(::Type{T}, m::Int) where T 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(::Array{Float64,2}) at /home/yves/.julia/v0.6/PlotRecipes/src/graphs.jl:44
[4] macro expansion at /home/yves/.julia/v0.6/PlotRecipes/src/graphs.jl:247 [inlined]
[5] apply_recipe(::Dict{Symbol,Any}, ::PlotRecipes.GraphPlot) at /home/yves/.julia/v0.6/RecipesBase/src/RecipesBase.jl:287
[6] _process_userrecipes(::Plots.Plot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}, ::Tuple{PlotRecipes.GraphPlot}) at /home/yves/.julia/v0.6/Plots/src/pipeline.jl:81
[7] _plot!(::Plots.Plot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}, ::Tuple{PlotRecipes.GraphPlot}) at /home/yves/.julia/v0.6/Plots/src/plot.jl:175
[8] (::RecipesBase.#kw##plot)(::Array{Any,1}, ::RecipesBase.#plot, ::PlotRecipes.GraphPlot) at ./<missing>:0
[9] #graphplot#29(::Array{Any,1}, ::Function, ::Array{Float64,2}, ::Vararg{Array{Float64,2},N} where N) at /home/yves/.julia/v0.6/RecipesBase/src/RecipesBase.jl:363
[10] (::PlotRecipes.#kw##graphplot)(::Array{Any,1}, ::PlotRecipes.#graphplot, ::Array{Float64,2}, ::Vararg{Array{Float64,2},N} where N) at ./<missing>:0
[11] eval(::Module, ::Any) at ./boot.jl:235
[12] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
[13] macro expansion at ./REPL.jl:97 [inlined]
[14] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading no file, in expression starting on line 0
WARNING: Array(::Type{T}, m::Int) where T 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(::Array{Float64,2}) at /home/yves/.julia/v0.6/PlotRecipes/src/graphs.jl:45
[4] macro expansion at /home/yves/.julia/v0.6/PlotRecipes/src/graphs.jl:247 [inlined]
[5] apply_recipe(::Dict{Symbol,Any}, ::PlotRecipes.GraphPlot) at /home/yves/.julia/v0.6/RecipesBase/src/RecipesBase.jl:287
[6] _process_userrecipes(::Plots.Plot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}, ::Tuple{PlotRecipes.GraphPlot}) at /home/yves/.julia/v0.6/Plots/src/pipeline.jl:81
[7] _plot!(::Plots.Plot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}, ::Tuple{PlotRecipes.GraphPlot}) at /home/yves/.julia/v0.6/Plots/src/plot.jl:175
[8] (::RecipesBase.#kw##plot)(::Array{Any,1}, ::RecipesBase.#plot, ::PlotRecipes.GraphPlot) at ./<missing>:0
[9] #graphplot#29(::Array{Any,1}, ::Function, ::Array{Float64,2}, ::Vararg{Array{Float64,2},N} where N) at /home/yves/.julia/v0.6/RecipesBase/src/RecipesBase.jl:363
[10] (::PlotRecipes.#kw##graphplot)(::Array{Any,1}, ::PlotRecipes.#graphplot, ::Array{Float64,2}, ::Vararg{Array{Float64,2},N} where N) at ./<missing>:0
[11] eval(::Module, ::Any) at ./boot.jl:235
[12] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
[13] macro expansion at ./REPL.jl:97 [inlined]
[14] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading no file, in expression starting on line 0
Error showing value of type Plots.Plot{Plots.PyPlotBackend}:
ERROR: PyError (ccall(@pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, arg, kw)) <class 'ValueError'>
ValueError('Invalid RGBA argument: 1.0',)
File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line 1894, in inner
return func(ax, *args, **kwargs)
File "/usr/lib/python3/dist-packages/matplotlib/axes/_axes.py", line 4028, in scatter
alpha=alpha
File "/usr/lib/python3/dist-packages/matplotlib/collections.py", line 890, in __init__
Collection.__init__(self, **kwargs)
File "/usr/lib/python3/dist-packages/matplotlib/collections.py", line 139, in __init__
self.set_facecolor(facecolors)
File "/usr/lib/python3/dist-packages/matplotlib/collections.py", line 674, in set_facecolor
self._set_facecolor(c)
File "/usr/lib/python3/dist-packages/matplotlib/collections.py", line 659, in _set_facecolor
self._facecolors = mcolors.to_rgba_array(c, self._alpha)
File "/usr/lib/python3/dist-packages/matplotlib/colors.py", line 237, in to_rgba_array
result[i] = to_rgba(cc, alpha)
File "/usr/lib/python3/dist-packages/matplotlib/colors.py", line 143, in to_rgba
rgba = _to_rgba_no_colorcycle(c, alpha)
File "/usr/lib/python3/dist-packages/matplotlib/colors.py", line 194, in _to_rgba_no_colorcycle
raise ValueError("Invalid RGBA argument: {!r}".format(orig_c))
EDIT: the second example (Arc and chord diagrams) works fine.
Replacing the call to graphplot with
graphplot(A,
node_weights = 1:n,
nodeshape = :rect,
line = (3, 0.5, :blue),
nodeweights = 1:n,
names = 1:n
)
Gets rid of the error for me. @my-little-repository does that fix work for you too?