-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update plot.jl to account for line style #176
base: master
Are you sure you want to change the base?
Changes from all commits
608552b
921d54d
40f1010
816106d
39e27ad
387d1a9
94ec1d3
81a9cdf
0b79a11
298a83a
bf1a00d
3f20a19
13fb265
f108307
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,15 @@ edgelabel = 1:Graphs.ne(g) | |
gplot(g, edgelabel=edgelabel, nodelabel=nodelabel, edgelabeldistx=0.5, edgelabeldisty=0.5) | ||
``` | ||
|
||
## Add dash style to edges | ||
```julia | ||
using Measures | ||
gplot(g, edgedashstyle=[5mm, 2mm]) | ||
# vary edge styles | ||
using Compose | ||
gplot(g, EDGELINEWIDTH=0.7, edgedashstyle=[[10px, 5px], [10px, 5px, 3px, 5px], [4px, 4px], []]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of this kwarg should be properly documented. When vectors are passed for each edge, the values define the sequence of dashes and spaces. For example, the first edge will have 10px solid dash with 5px spacing in between; the second edge will have the following alternating sequence: 10px solid - 5 px space - 3px solid - 5 px space - etc... |
||
``` | ||
|
||
## Color the graph | ||
```julia | ||
# nodes membership | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,9 @@ Optional. Relative line width for the edges, can be a Vector. Default: `1.0` | |
`edgestrokec` | ||
Optional. Color for the edge strokes, can be a Vector. Default: `colorant"lightgray"` | ||
|
||
`edgedashstyle` | ||
Optional. Dash style for the edge, can be a Vector. Default: no dashed line. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default here is |
||
|
||
`arrowlengthfrac` | ||
Optional. Fraction of line length to use for arrows. | ||
Equal to 0 for undirected graphs. Default: `0.1` for the directed graphs | ||
|
@@ -96,6 +99,7 @@ function gplot(g::AbstractGraph{T}, | |
edgelabel = [], | ||
edgelabelc = colorant"black", | ||
edgelabelsize = 1.0, | ||
edgedashstyle = [], | ||
EDGELABELSIZE = 4.0, | ||
edgestrokec = colorant"lightgray", | ||
edgelinewidth = 1.0, | ||
|
@@ -138,6 +142,9 @@ function gplot(g::AbstractGraph{T}, | |
map!(z -> scaler(z, min_x, max_x), locs_x, locs_x) | ||
map!(z -> scaler(z, min_y, max_y), locs_y, locs_y) | ||
|
||
# Calculate the size of the box | ||
units = UnitBox(-1.2, -1.2, 2.4, 2.4) | ||
|
||
# Determine sizes | ||
#NODESIZE = 0.25/sqrt(N) | ||
#LINEWIDTH = 3.0/sqrt(N) | ||
|
@@ -217,12 +224,12 @@ function gplot(g::AbstractGraph{T}, | |
end | ||
end | ||
|
||
compose(context(units=UnitBox(-1.2, -1.2, +2.4, +2.4)), | ||
compose(context(units=units), | ||
compose(context(), texts, fill(nodelabelc), stroke(nothing), fontsize(nodelabelsize)), | ||
compose(context(), nodes, fill(nodefillc), stroke(nodestrokec), linewidth(nodestrokelw)), | ||
compose(context(), edgetexts, fill(edgelabelc), stroke(nothing), fontsize(edgelabelsize)), | ||
compose(context(), arrows, stroke(edgestrokec), linewidth(edgelinewidth)), | ||
compose(context(), lines, stroke(edgestrokec), fill(nothing), linewidth(edgelinewidth))) | ||
compose(context(), lines, stroke(edgestrokec), strokedash(edgedashstyle), fill(nothing), linewidth(edgelinewidth))) | ||
end | ||
|
||
function gplot(g; layout::Function=spring_layout, keyargs...) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of this kwarg should be properly documented. In this case, one edge will have 5mm dashes and the next will have 2mm dashes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, all edges will have the same style, that is alternating 5mm solid line and 2mm blank line.