Skip to content

Commit

Permalink
New doc for drawing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothée Poisot committed Aug 19, 2015
1 parent 040a991 commit 080ea70
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
32 changes: 32 additions & 0 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@

---

<a id="method__draw_matrix.1" class="lexicon_definition"></a>
#### draw_matrix(M::Modular) [](#method__draw_matrix.1)

Takes a `Modular` object, and plot it using the *Cairo* driver.

**Keyword arguments:**

- `reorder::Function`, a function to change the order of species (by default, `reorder_by_module!`)
- `file`: the name of the file to draw in (has to end in `.png`)

Note that the modules are identified by color, using the
`distinguishable_colors` function from the `Colors` package.


*source:*
[Brim/src/draw_matrix.jl:44](file:///home/tpoisot/.julia/v0.3/Brim/src/draw_matrix.jl)

---

<a id="method__no_empty_modules.1" class="lexicon_definition"></a>
#### no_empty_modules!(M::Modular) [](#method__no_empty_modules.1)

Expand Down Expand Up @@ -54,6 +73,18 @@ cannot have empty rows or columns.
*source:*
[Brim/src/permutations.jl:100](file:///home/tpoisot/.julia/v0.3/Brim/src/permutations.jl)

---

<a id="method__reorder_by_module.1" class="lexicon_definition"></a>
#### reorder_by_module!(M::Modular) [](#method__reorder_by_module.1)

Takes a `Modular` object, and reorder it by module. The row / columns of `A` and
`S` are modified.


*source:*
[Brim/src/draw_matrix.jl:5](file:///home/tpoisot/.julia/v0.3/Brim/src/draw_matrix.jl)

## Internal

---
Expand Down Expand Up @@ -112,3 +143,4 @@ Also, this is a serious lot of documentation in a function that is not exported.

*source:*
[Brim/src/permutations.jl:38](file:///home/tpoisot/.julia/v0.3/Brim/src/permutations.jl)

1 change: 1 addition & 0 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Coverage Status](https://coveralls.io/repos/PoisotLab/Brim.jl/badge.svg?branch=master)](https://coveralls.io/r/PoisotLab/Brim.jl?branch=master)
[![codecov.io](http://codecov.io/github/PoisotLab/Brim.jl/coverage.svg?branch=master)](http://codecov.io/github/PoisotLab/Brim.jl?branch=master)
[![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.16579.svg)](http://dx.doi.org/10.5281/zenodo.16579)
[![Documentation Status](https://readthedocs.org/projects/brimjl/badge/?version=latest)](https://readthedocs.org/projects/brimjl/?badge=latest)

Various ways to optimize the modularity of bipartite networks using BRIM in
`Julia`.
Expand Down
21 changes: 18 additions & 3 deletions src/draw_matrix.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Takes a `Modular` object, and reorder it by module. The row / columns of `A` and
`S` are modified.
"""
function reorder_by_module!(M::Modular)
nA = zeros(M.A)
nS = zeros(M.S)
Expand Down Expand Up @@ -26,24 +30,35 @@ function reorder_by_module!(M::Modular)
M.S = nS
end

"""
Takes a `Modular` object, and plot it using the *Cairo* driver.
**Keyword arguments:**
- `reorder::Function`, a function to change the order of species (by default, `reorder_by_module!`)
- `file`: the name of the file to draw in (has to end in `.png`)
Note that the modules are identified by color, using the
`distinguishable_colors` function from the `Colors` package.
"""
function draw_matrix(M::Modular; reorder::Function = reorder_by_module!, file="modular.png")
reorder(M)
number_modules = size(M.S)[2]
module_color = distinguishable_colors(number_modules)
nbot, ntop = size(M.A)
width = 4 + nbot*(10+4)
height = 4 + ntop*(10+4)
## Initialize device
# Initialize device
c = CairoRGBSurface(width, height)
cr = CairoContext(c)
save(cr)
## Background
# Background
set_source_rgba(cr, 1.0, 1.0, 1.0, 1.0)
rectangle(cr, 0.0, 0.0, float(width), float(height))
fill(cr)
restore(cr)
save(cr)
## Draw the blocks
# Draw the blocks
for top in 1:ntop
for bot in 1:nbot
if M.A[bot,top] > 0
Expand Down

0 comments on commit 080ea70

Please sign in to comment.