@@ -18,41 +18,41 @@ From the Julia REPL the latest version can be installed with
1818Pkg.add("GraphPlot")
1919```
2020GraphPlot is then loaded with
21- ```
21+ ``` julia
2222using GraphPlot
2323```
2424
2525# Usage
2626## karate network
27- ```
27+ ``` julia
2828g = graphfamous (" karate" )
2929gplot (g)
3030
3131```
3232
3333## Add node label
34- ```
34+ ``` julia
3535using Graphs
3636nodelabel = [1 : num_vertices (g)]
3737gplot (g, nodelabel= nodelabel)
3838
3939```
4040
4141## Adjust node labels
42- ```
42+ ``` julia
4343gplot (g, nodelabel= nodelabel, nodelabeldist= 1.5 , nodelabelangleoffset= π/ 4 )
4444```
4545
4646## Control the node size
47- ```
47+ ``` julia
4848# nodes size proportional to their degree
4949nodesize = [Graphs. out_degree (v, g) for v in Graphs. vertices (g)]
5050gplot (g, nodesize= nodesize)
5151```
5252
5353## Control the node color
5454Feed the keyword argument ` nodefillc ` a color array, ensure each node has a color. ` length(nodefillc) ` must be equal ` |V| ` .
55- ```
55+ ``` julia
5656using Colors
5757
5858# Generate n maximally distinguishable colors in LCHab space.
@@ -61,32 +61,32 @@ gplot(g, nodefillc=nodefillc, nodelabel=nodelabel, nodelabeldist=1.8, nodelabela
6161```
6262
6363## Transparent
64- ```
64+ ``` julia
6565# stick out large degree nodes
6666alphas = nodesize/ maximum (nodesize)
6767nodefillc = [RGBA (0.0 ,0.8 ,0.8 ,i) for i in alphas]
6868gplot (g, nodefillc= nodefillc)
6969```
7070## Control the node label size
71- ```
71+ ``` julia
7272nodelabelsize = nodesize
7373gplot (g, nodelabelsize= nodelabelsize, nodesize= nodesize, nodelabel= nodelabel)
7474```
7575
7676## Draw edge labels
77- ```
77+ ``` julia
7878edgelabel = [1 : Graphs. num_edges (g)]
7979gplot (g, edgelabel= edgelabel, nodelabel= nodelabel)
8080```
8181
8282## Adjust edge labels
83- ```
83+ ``` julia
8484edgelabel = [1 : Graphs. num_edges (g)]
8585gplot (g, edgelabel= edgelabel, nodelabel= nodelabel, edgelabeldistx= 0.5 , edgelabeldisty= 0.5 )
8686```
8787
8888## Color the graph
89- ```
89+ ``` julia
9090# nodes membership
9191membership = [1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,2 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,1 ,1 ,2 ,1 ,2 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ]
9292nodecolor = [colorant " lightseagreen" , colorant " orange" ]
@@ -97,19 +97,19 @@ gplot(g, nodefillc=nodefillc)
9797
9898## Different layout
9999### random layout
100- ```
100+ ``` julia
101101gplot (g, layout= random_layout, nodelabel= nodelabel)
102102```
103103### circular layout
104- ```
104+ ``` julia
105105gplot (g, layout= circular_layout, nodelabel= nodelabel)
106106```
107107### spectral layout
108- ```
108+ ``` julia
109109gplot (g, layout= spectral_layout)
110110```
111111### shell layout
112- ```
112+ ``` julia
113113nlist = Array (Vector{Int}, 2 ) # two shells
114114nlist[1 ] = [1 : 5 ] # first shell
115115nlist[2 ] = [6 : num_vertices (g)] # second shell
@@ -118,7 +118,7 @@ gplot(g, locs_x, locs_y, nodelabel=nodelabel)
118118```
119119
120120## Curve edge
121- ```
121+ ``` julia
122122gplot (g, linetype= " curve" )
123123```
124124
@@ -133,7 +133,7 @@ draw(PNG("karate.png", 16cm, 16cm), gplot(g))
133133draw(SVG("karate.svg", 16cm, 16cm), gplot(g))
134134```
135135# LightGraphs integration
136- ```
136+ ``` julia
137137using LightGraphs
138138h = watts_strogatz (50 , 6 , 0.3 )
139139gplot (h)
@@ -157,4 +157,3 @@ Set to 0 for no arrows. Default: 0 for undirected graph and 0.1 for directed gra
157157# Reporting Bugs
158158
159159Filing an issue to report a bug, counterintuitive behavior, or even to request a feature is extremely valuable in helping me prioritize what to work on, so don't hestitate.
160-
0 commit comments