Skip to content

Commit

Permalink
Updating figures
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Jun 27, 2024
1 parent cf10002 commit f0e00f2
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 229 deletions.
2 changes: 1 addition & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
^\.Rproj\.user$
^playground$
^LICENSE\.md$
^README\.Rmd$
^README\.qmd$
^docs$
^docker$
^\.travis\.yml$
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@

/doc/
/Meta/

/.quarto/
30 changes: 15 additions & 15 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# netplot 0.2-9999

* Invalid arguments passed to `nplot()` now raise an error.
* Invalid arguments passed to `nplot()` now raise an error.

* Figures with legends are not drawn twice.
* Figures with legends are not drawn twice.

* Values supported by `nplot()` are now included in all methods (helps with
argument completion).
* Values supported by `nplot()` are now included in all methods (helps with
argument completion).


# netplot 0.2-0

* The arguments `skip.vertex`, `skip.edges`, and `skip.arrows` now work as
documented.

* New function `nplot_legend()` helps adding legends to the figure.
* The arguments `skip.vertex`, `skip.edges`, and `skip.arrows` now work as
documented.

* New `nplot()` method for matrices.
* New function `nplot_legend()` helps to add legends to the figure.

* New feature: Gradients.
* New `nplot()` method for matrices.

* The argument `sample.edges` now works as expected.
* New feature: Gradients.

* `vertex.color`, `vertex.size`, and `vertex.nsides` now accepts formulas.
* The argument `sample.edges` now work as expected.

* `edge.width` now accepts formulas.
* `vertex.color`, `vertex.size`, and `vertex.nsides` now accepts formulas.

* New function: `locate_vertex()`.
* `edge.width` now accepts formulas.

* New function: `locate_vertex()`.


# netplot 0.1-0

* First CRAN release.
* First CRAN release.
113 changes: 88 additions & 25 deletions R/netplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,9 @@ nplot <- function(
skip.arrows = skip.edges,
add = FALSE,
zero.margins = TRUE,
...,
edgelist
) {

# Checking if the passed arguments match the default class
res <- sapply(
...names(),
match.arg,
choices = methods::formalArgs(nplot.default),
several.ok = FALSE
)

UseMethod("nplot")

}
Expand Down Expand Up @@ -171,22 +162,44 @@ nplot.igraph <- function(
skip.arrows = !igraph::is_directed(x),
add = FALSE,
zero.margins = TRUE,
...,
edgelist
) {

if (!length(edge.width))
edge.width <- 1L

nplot.default(
x = x,
edgelist = igraph::as_edgelist(x, names = FALSE),
layout = layout,
vertex.size = vertex.size,
x = x,
layout = layout,
vertex.size = vertex.size,
bg.col = bg.col,
vertex.nsides = vertex.nsides,
vertex.color = vertex.color,
vertex.size.range = vertex.size.range,
vertex.frame.color = vertex.frame.color,
vertex.rot = vertex.rot,
vertex.frame.prop = vertex.frame.prop,
vertex.label = vertex.label,
edge.width = edge.width,
vertex.label.fontsize = vertex.label.fontsize,
vertex.label.color = vertex.label.color,
vertex.label.fontfamily = vertex.label.fontfamily,
vertex.label.fontface = vertex.label.fontface,
vertex.label.show = vertex.label.show,
vertex.label.range = vertex.label.range,
edge.width = edge.width,
edge.width.range = edge.width.range,
edge.arrow.size = edge.arrow.size,
edge.color = edge.color,
edge.curvature = edge.curvature,
edge.line.lty = edge.line.lty,
edge.line.breaks = edge.line.breaks,
sample.edges = sample.edges,
skip.vertex = skip.vertex,
skip.edges = skip.edges,
skip.arrows = skip.arrows,
...
add = add,
zero.margins = zero.margins,
edgelist = igraph::as_edgelist(x, names = FALSE)
)

}
Expand Down Expand Up @@ -226,18 +239,41 @@ nplot.network <- function(
skip.arrows = !network::is.directed(x),
add = FALSE,
zero.margins = TRUE,
...,
edgelist
) {

nplot.default(
x = x,
layout = layout,
vertex.size = vertex.size,
x = x,
layout = layout,
vertex.size = vertex.size,
bg.col = bg.col,
vertex.nsides = vertex.nsides,
vertex.color = vertex.color,
vertex.size.range = vertex.size.range,
vertex.frame.color = vertex.frame.color,
vertex.rot = vertex.rot,
vertex.frame.prop = vertex.frame.prop,
vertex.label = vertex.label,
skip.arrows = skip.arrows,
...,
edgelist = network::as.edgelist(x)
vertex.label.fontsize = vertex.label.fontsize,
vertex.label.color = vertex.label.color,
vertex.label.fontfamily = vertex.label.fontfamily,
vertex.label.fontface = vertex.label.fontface,
vertex.label.show = vertex.label.show,
vertex.label.range = vertex.label.range,
edge.width = edge.width,
edge.width.range = edge.width.range,
edge.arrow.size = edge.arrow.size,
edge.color = edge.color,
edge.curvature = edge.curvature,
edge.line.lty = edge.line.lty,
edge.line.breaks = edge.line.breaks,
sample.edges = sample.edges,
skip.vertex = skip.vertex,
skip.edges = skip.edges,
skip.arrows = skip.arrows,
add = add,
zero.margins = zero.margins,
edgelist = network::as.edgelist(x)
)

}
Expand Down Expand Up @@ -276,13 +312,40 @@ nplot.matrix <- function(
skip.arrows = skip.edges,
add = FALSE,
zero.margins = TRUE,
...,
edgelist
) {

nplot.igraph(
x = igraph::graph_from_adjacency_matrix(x),
...,
layout = layout,
vertex.size = vertex.size,
bg.col = bg.col,
vertex.nsides = vertex.nsides,
vertex.color = vertex.color,
vertex.size.range = vertex.size.range,
vertex.frame.color = vertex.frame.color,
vertex.rot = vertex.rot,
vertex.frame.prop = vertex.frame.prop,
vertex.label = vertex.label,
vertex.label.fontsize = vertex.label.fontsize,
vertex.label.color = vertex.label.color,
vertex.label.fontfamily = vertex.label.fontfamily,
vertex.label.fontface = vertex.label.fontface,
vertex.label.show = vertex.label.show,
vertex.label.range = vertex.label.range,
edge.width = edge.width,
edge.width.range = edge.width.range,
edge.arrow.size = edge.arrow.size,
edge.color = edge.color,
edge.curvature = edge.curvature,
edge.line.lty = edge.line.lty,
edge.line.breaks = edge.line.breaks,
sample.edges = sample.edges,
skip.vertex = skip.vertex,
skip.edges = skip.edges,
skip.arrows = skip.arrows,
add = add,
zero.margins = zero.margins,
edgelist = NULL
)

Expand Down
Loading

0 comments on commit f0e00f2

Please sign in to comment.