Skip to content

Commit

Permalink
Merge pull request #19 from EcoJulia/force-dir
Browse files Browse the repository at this point in the history
🙂 simplify the FD code
  • Loading branch information
tpoisot authored Nov 25, 2020
2 parents 387144c + efbf577 commit 75a2645
Show file tree
Hide file tree
Showing 15 changed files with 341 additions and 293 deletions.
16 changes: 13 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ using Documenter, EcologicalNetworksPlots

const pages = [
"Index" => "index.md",
"Examples" => "examples.md",
"Reference" => "library.md"
"Layouts" => [
"Introduction" => "layouts/initial.md",
"Circular" => "layouts/circular.md",
"Bipartite" => "layouts/bipartite.md",
"Force-directed" => "layouts/forcedirected.md",
"Unravel" => "layouts/unravelled.md"
],
"Advanced topics" => [
"Nodes attributes" => "advanced/attributes.md",
"Networks subsets" => "advanced/subsets.md",
]
# TODO add plotting, heatmap, advanced uses
]

makedocs(
Expand All @@ -15,6 +25,6 @@ makedocs(
)

deploydocs(
repo = "github.com/PoisotLab/EcologicalNetworksPlots.jl.git",
repo = "github.com/EcoJulia/EcologicalNetworksPlots.jl.git",
push_preview = true
)
39 changes: 39 additions & 0 deletions docs/src/advanced/attributes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## Node color

```@setup default
using EcologicalNetworks
using EcologicalNetworksPlots
using Plots
```

```@example default
Unes = web_of_life("M_SD_033")
I = initial(BipartiteInitialLayout, Unes)
position!(NestedBipartiteLayout(0.4), I, Unes)
plot(I, Unes, aspectratio=1)
scatter!(I, Unes, bipartite=true, nodefill=degree(Unes), c=:cividis)
```

## Node size

The size of the nodes can be changed using the `nodesize` argument, which is a
dictionary mapping species to values. These values are scaled when making the
figures. Note that in this example we also label the number of the node.

```@example default
Unes = web_of_life("M_SD_033")
I = initial(BipartiteInitialLayout, Unes)
position!(NestedBipartiteLayout(0.4), I, Unes)
plot(I, Unes, aspectratio=1)
scatter!(I, Unes, bipartite=true, nodesize=degree(Unes))
```

## Node annotations

```@example default
Unes = web_of_life("M_SD_033")
I = initial(BipartiteInitialLayout, Unes)
position!(NestedBipartiteLayout(0.4), I, Unes)
plot(I, Unes, aspectratio=1)
scatter!(I, Unes, bipartite=true, series_annotations = string.(1:richness(Unes)))
```
23 changes: 23 additions & 0 deletions docs/src/advanced/subsets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
```@setup default
using EcologicalNetworks
using EcologicalNetworksPlots
using Plots
```

One important feature of the package is that the layout can contain *more* nodes
than the network. For example, we can use this to our advantage, to represent
species with a degree larger than 3 in red:

```@example default
Umod = web_of_life("M_PA_003")
I = initial(RandomInitialLayout, Umod)
for step in 1:4000
position!(ForceDirectedLayout(2.5, 0.4), I, Umod)
end
plot(I, Umod, aspectratio=1)
scatter!(I, Umod)
N = convert(AbstractUnipartiteNetwork, convert(BinaryNetwork, Umod))
core3 = collect(keys(filter(p -> p.second == 3, degree(N))))
plot!(I, N[core3], lc=:red)
scatter!(I, N[core3], mc=:red)
```
Binary file added docs/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
163 changes: 0 additions & 163 deletions docs/src/examples.md

This file was deleted.

14 changes: 10 additions & 4 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ The second option requires to set a layout, of which there are multiple types
according to the type of network, the type of layout, and the information to
emphasize. Applying a layout consists of a call to `initial`, followed by one or
more calls to `position!`. The *nodes* in the network are represented using
`scatter`, and the *links* using `plot`.

Probabilistic networks have link *probability* denoted as transparency, and
quantitative network have link *strength* represented as width.
`scatter`, and the *links* using `plot`. Probabilistic networks have link
*probability* denoted as transparency, and quantitative network have link
*strength* represented as width.

Both the fill and color of the nodes can be changed, using the `nodefill`
and `nodesize` arguments -- these must be dictionaries mapping *all nodes* in
the network to a single numerical value, and they affect the `markerfill` and
`markerz` value of `Plots`, respectively. Note that by default, `frametype` is
`:none` and `legend` is `false`, but this can be changed. It is particularly
important to change it for `UnravelledLayout`, for example.

An important point, which can be used to create complex visualisations, is that
you can call the `scatter` and `plot` functions on dictionaries of positions
that have *more* points that are in the network. This can, among other things,
allow you to use different colormaps for the degree of different nodes, or color
different sub-graphs in the network. There are a few example of these uses in
the documentation.
22 changes: 22 additions & 0 deletions docs/src/layouts/bipartite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Layouts

```@docs
BipartiteInitialLayout
NestedBipartiteLayout
```

```@setup default
using EcologicalNetworks
using EcologicalNetworksPlots
using Plots
```

## Example

```@example default
Unes = web_of_life("M_SD_033")
I = initial(BipartiteInitialLayout, Unes)
position!(NestedBipartiteLayout(0.4), I, Unes)
plot(I, Unes, aspectratio=1)
scatter!(I, Unes, bipartite=true)
```
22 changes: 22 additions & 0 deletions docs/src/layouts/circular.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Layouts

```@docs
CircularInitialLayout
CircularLayout
```

```@setup default
using EcologicalNetworks
using EcologicalNetworksPlots
using Plots
```

## Example

```@example default
Unes = web_of_life("M_SD_033")
I = initial(CircularInitialLayout, Unes)
position!(CircularLayout(), I, Unes)
plot(I, Unes, aspectratio=1)
scatter!(I, Unes, bipartite=true)
```
Loading

2 comments on commit 75a2645

@tpoisot
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/25289

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.0.7 -m "<description of version>" 75a2645d81732aafb6340ed30b7ee1746795332a
git push origin v0.0.7

Please sign in to comment.