@@ -42,10 +42,10 @@ Distances for the node labels from center of nodes. Default: `0.0`
42
42
Angle offset for the node labels. Default: `π/4.0`
43
43
44
44
`NODELABELSIZE`
45
- Largest fontsize for the vertice labels. Default: `4.0`
45
+ Largest fontsize for the vertex labels. Default: `4.0`
46
46
47
47
`nodelabelsize`
48
- Relative fontsize for the vertice labels, can be a Vector. Default: `1.0`
48
+ Relative fontsize for the vertex labels, can be a Vector. Default: `1.0`
49
49
50
50
`nodefillc`
51
51
Color to fill the nodes with, can be a Vector. Default: `colorant"turquoise"`
@@ -94,6 +94,9 @@ Type of line used for edges ("straight", "curve"). Default: "straight"
94
94
Angular width in radians for the edges (only used if `linetype = "curve`).
95
95
Default: `π/5 (36 degrees)`
96
96
97
+ `backgroundc`
98
+ Color for the plot background. Default: `nothing`
99
+
97
100
"""
98
101
function gplot (g:: AbstractGraph{T} ,
99
102
locs_x_in:: Vector{R1} , locs_y_in:: Vector{R2} ;
@@ -120,7 +123,8 @@ function gplot(g::AbstractGraph{T},
120
123
arrowlengthfrac = is_directed (g) ? 0.1 : 0.0 ,
121
124
arrowangleoffset = π / 9 ,
122
125
linetype = " straight" ,
123
- outangle = π / 5 ) where {T <: Integer , R1 <: Real , R2 <: Real }
126
+ outangle = π / 5 ,
127
+ backgroundc = nothing ) where {T <: Integer , R1 <: Real , R2 <: Real }
124
128
125
129
length (locs_x_in) != length (locs_y_in) && error (" Vectors must be same length" )
126
130
N = nv (g)
@@ -169,19 +173,19 @@ function gplot(g::AbstractGraph{T},
169
173
# Create nodes
170
174
nodecircle = fill (0.4 Compose. w, length (locs_x))
171
175
if isa (nodesize, Real)
172
- for i = 1 : length (locs_x)
173
- nodecircle[i] *= nodesize
174
- end
175
- else
176
- for i = 1 : length (locs_x)
177
- nodecircle[i] *= nodesize[i]
178
- end
179
- end
176
+ for i = 1 : length (locs_x)
177
+ nodecircle[i] *= nodesize
178
+ end
179
+ else
180
+ for i = 1 : length (locs_x)
181
+ nodecircle[i] *= nodesize[i]
182
+ end
183
+ end
180
184
nodes = circle (locs_x, locs_y, nodecircle)
181
185
182
186
# Create node labels if provided
183
187
texts = nothing
184
- if nodelabel != nothing
188
+ if ! isnothing (nodelabel)
185
189
text_locs_x = deepcopy (locs_x)
186
190
text_locs_y = deepcopy (locs_y)
187
191
texts = text (text_locs_x .+ nodesize .* (nodelabeldist * cos (nodelabelangleoffset)),
@@ -227,7 +231,7 @@ function gplot(g::AbstractGraph{T},
227
231
end
228
232
end
229
233
230
- compose (context (units= UnitBox (- 1.2 , - 1.2 , + 2.4 , + 2.4 )),
234
+ compose (context (units= UnitBox (- 1.2 , - 1.2 , + 2.4 , + 2.4 )), rectangle ( - 1.2 , - 1.2 , + 2.4 , + 2.4 ), fill (backgroundc),
231
235
compose (context (), texts, fill (nodelabelc), stroke (nothing ), fontsize (nodelabelsize)),
232
236
compose (context (), nodes, fill (nodefillc), stroke (nodestrokec), linewidth (nodestrokelw)),
233
237
compose (context (), edgetexts, fill (edgelabelc), stroke (nothing ), fontsize (edgelabelsize)),
0 commit comments