GraphPlots - 有没有办法为边缘设置不同的颜色?
GraphPlots - Is there a way to have different colors for edges?
Given GraphPlots doc,我们有以下可用属性:
function gplot{V, T<:Real}(
G::AbstractGraph{V},
locs_x::Vector{T}, locs_y::Vector{T};
nodelabel::Union(Nothing, Vector) = nothing,
nodelabelc::ComposeColor = colorant"black",
nodelabelsize::Union(Real, Vector) = 4,
nodelabeldist::Real = 0,
nodelabelangleoffset::Real = π/4.0,
edgelabel::Union(Nothing, Vector) = nothing,
edgelabelc::ComposeColor = colorant"black",
edgelabelsize::Union(Real, Vector) = 4,
edgestrokec::ComposeColor = colorant"lightgray",
edgelinewidth::Union(Real, Vector) = 1,
edgelabeldistx::Real = 0,
edgelabeldisty::Real = 0,
nodesize::Union(Real, Vector) = 1,
nodefillc::ComposeColor = colorant"turquoise",
nodestrokec::ComposeColor = nothing,
nodestrokelw::Union(Real, Vector) = 0,
arrowlengthfrac::Real = Graphs.is_directed(G) ? 0.1 : 0.0,
arrowangleoffset = 20.0/180.0*π)
edgestrokec
允许改变边缘的颜色。但是,我的图形中有两种类型的边,我想用两种不同的颜色为它们着色。可能吗?
if !plot_backup_edge
for i in 1:length(hubs)-1
add_edge!(inst_graph, hubs[i], hubs[i+1])
## TODO: Have a first color here for the edges
end
add_edge!(inst_graph, hubs[1], hubs[end])
end
if plot_backup_edge
for i in 2:length(hubs)-1
add_edge!(inst_graph, hubs[i-1], hubs[i+1])
## TODO: Have a second color here for the edges
end
add_edge!(inst_graph, hubs[end-1], hubs[2])
end
使用edgestrokec
:
using Colors
G = Graph(8,12)
gplot(G;edgestrokec =rand([colorant"red", colorant"green", colorant"blue"],12))
Given GraphPlots doc,我们有以下可用属性:
function gplot{V, T<:Real}(
G::AbstractGraph{V},
locs_x::Vector{T}, locs_y::Vector{T};
nodelabel::Union(Nothing, Vector) = nothing,
nodelabelc::ComposeColor = colorant"black",
nodelabelsize::Union(Real, Vector) = 4,
nodelabeldist::Real = 0,
nodelabelangleoffset::Real = π/4.0,
edgelabel::Union(Nothing, Vector) = nothing,
edgelabelc::ComposeColor = colorant"black",
edgelabelsize::Union(Real, Vector) = 4,
edgestrokec::ComposeColor = colorant"lightgray",
edgelinewidth::Union(Real, Vector) = 1,
edgelabeldistx::Real = 0,
edgelabeldisty::Real = 0,
nodesize::Union(Real, Vector) = 1,
nodefillc::ComposeColor = colorant"turquoise",
nodestrokec::ComposeColor = nothing,
nodestrokelw::Union(Real, Vector) = 0,
arrowlengthfrac::Real = Graphs.is_directed(G) ? 0.1 : 0.0,
arrowangleoffset = 20.0/180.0*π)
edgestrokec
允许改变边缘的颜色。但是,我的图形中有两种类型的边,我想用两种不同的颜色为它们着色。可能吗?
if !plot_backup_edge
for i in 1:length(hubs)-1
add_edge!(inst_graph, hubs[i], hubs[i+1])
## TODO: Have a first color here for the edges
end
add_edge!(inst_graph, hubs[1], hubs[end])
end
if plot_backup_edge
for i in 2:length(hubs)-1
add_edge!(inst_graph, hubs[i-1], hubs[i+1])
## TODO: Have a second color here for the edges
end
add_edge!(inst_graph, hubs[end-1], hubs[2])
end
使用edgestrokec
:
using Colors
G = Graph(8,12)
gplot(G;edgestrokec =rand([colorant"red", colorant"green", colorant"blue"],12))