@@ -54,10 +54,10 @@ Distances for the node labels from center of nodes. Default: `0.0`
5454Angle offset for the node labels. Default: `π/4.0`
5555
5656`NODELABELSIZE`
57- Largest fontsize for the vertice labels. Default: `4.0`
57+ Largest fontsize for the vertex labels. Default: `4.0`
5858
5959`nodelabelsize`
60- Relative fontsize for the vertice labels, can be a Vector. Default: `1.0`
60+ Relative fontsize for the vertex labels, can be a Vector. Default: `1.0`
6161
6262`nodefillc`
6363Color to fill the nodes with, can be a Vector. Default: `colorant"turquoise"`
@@ -106,6 +106,9 @@ Type of line used for edges ("straight", "curve"). Default: "straight"
106106Angular width in radians for the edges (only used if `linetype = "curve`).
107107Default: `π/5 (36 degrees)`
108108
109+ `background_color`
110+ Color for the plot background. Default: `nothing`
111+
109112`plot_size`
110113Tuple of measures for width x height for plot area. Default: `(sqrt(2)*10cm, 10cm)`
111114
@@ -142,6 +145,7 @@ function gplot(g::AbstractGraph{T},
142145 arrowangleoffset = π / 9 ,
143146 linetype = " straight" ,
144147 outangle = π / 5 ,
148+ background_color = nothing ,
145149 plot_size = (sqrt (2 )* 10 cm, 10 cm),
146150 leftpad = 0 mm,
147151 rightpad = 0 mm,
@@ -196,19 +200,19 @@ function gplot(g::AbstractGraph{T},
196200 # Create nodes
197201 nodecircle = fill (0.4 Compose. w, length (locs_x))
198202 if isa (nodesize, Real)
199- for i = 1 : length (locs_x)
200- nodecircle[i] *= nodesize
201- end
202- else
203- for i = 1 : length (locs_x)
204- nodecircle[i] *= nodesize[i]
205- end
206- end
203+ for i = 1 : length (locs_x)
204+ nodecircle[i] *= nodesize
205+ end
206+ else
207+ for i = 1 : length (locs_x)
208+ nodecircle[i] *= nodesize[i]
209+ end
210+ end
207211 nodes = circle (locs_x, locs_y, nodecircle)
208212
209213 # Create node labels if provided
210214 texts = nothing
211- if nodelabel != nothing
215+ if ! isnothing (nodelabel)
212216 text_locs_x = deepcopy (locs_x)
213217 text_locs_y = deepcopy (locs_y)
214218 texts = text (text_locs_x .+ nodesize .* (nodelabeldist * cos (nodelabelangleoffset)),
@@ -252,16 +256,20 @@ function gplot(g::AbstractGraph{T},
252256 # Fix title offset
253257 title_offset = isempty (title) ? 0 : 0.1 * title_size/ 4
254258
259+ # Plot area size
260+ plot_area = (- 1.2 , - 1.2 - title_offset, + 2.4 , + 2.4 + title_offset)
261+
255262 # Build figure
256- compose (context (units= UnitBox (- 1.2 , - 1.2 - title_offset, + 2.4 , + 2.4 + title_offset ; leftpad, rightpad, toppad, bottompad)),
263+ compose (context (units= UnitBox (plot_area ... ; leftpad, rightpad, toppad, bottompad)),
257264 compose (context (), text (0 , - 1.2 - title_offset/ 2 , title, hcenter, vcenter), fill (title_color), fontsize (title_size), font (font_family)),
258265 compose (context (), texts, fill (nodelabelc), fontsize (nodelabelsize), font (font_family)),
259266 compose (context (), nodes, fill (nodefillc), stroke (nodestrokec), linewidth (nodestrokelw)),
260267 compose (context (), edgetexts, fill (edgelabelc), stroke (nothing ), fontsize (edgelabelsize)),
261268 compose (context (), larrows, stroke (edgestrokec), linewidth (edgelinewidth)),
262269 compose (context (), carrows, stroke (edgestrokec), linewidth (edgelinewidth)),
263270 compose (context (), lines, stroke (edgestrokec), fill (nothing ), linewidth (edgelinewidth)),
264- compose (context (), curves, stroke (edgestrokec), fill (nothing ), linewidth (edgelinewidth)))
271+ compose (context (), curves, stroke (edgestrokec), fill (nothing ), linewidth (edgelinewidth)),
272+ compose (context (), rectangle (plot_area... ), fill (background_color)))
265273end
266274
267275function gplot (g; layout:: Function = spring_layout, keyargs... )
0 commit comments