Skip to content

Commit

Permalink
plot_AbanicoPlot():
Browse files Browse the repository at this point in the history
+ ho code housekeeping
+ ad more tests
+ fx minor unused code issue in combination with the layout option
+ ad more tests
  • Loading branch information
RLumSK committed Dec 26, 2024
1 parent d7967cd commit 635688d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
32 changes: 13 additions & 19 deletions R/plot_AbanicoPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -582,21 +582,18 @@ plot_AbanicoPlot <- function(
}

## check/set layout definitions
if("layout" %in% names(list(...))) {
layout = get_Layout(layout = list(...)$layout)
} else {
if(!is.null(list(...)$layout))
layout <- get_Layout(layout = list(...)$layout)
else
layout <- get_Layout(layout = "default")
}

if(missing(stats) == TRUE) {
if(missing(stats))
stats <- numeric(0)
}

if(missing(bar) == TRUE) {
if(missing(bar))
bar <- rep(TRUE, length(data))
}

if(missing(bar.col) == TRUE) {
if(missing(bar.col)) {
bar.fill <- rep(x = rep(x = layout$abanico$colour$bar.fill,
length.out = length(data)), length(bar))
bar.line <- rep(rep(layout$abanico$colour$bar.line,
Expand All @@ -606,7 +603,7 @@ plot_AbanicoPlot <- function(
bar.line <- NA
}

if(missing(polygon.col) == TRUE) {
if(missing(polygon.col)) {
polygon.fill <- rep(layout$abanico$colour$poly.fill,
length.out = length(data))
polygon.line <- rep(layout$abanico$colour$poly.line,
Expand All @@ -616,7 +613,7 @@ plot_AbanicoPlot <- function(
polygon.line <- NA
}

if(missing(grid.col) == TRUE) {
if(missing(grid.col)) {
grid.major <- layout$abanico$colour$grid.major
grid.minor <- layout$abanico$colour$grid.minor
} else {
Expand All @@ -629,17 +626,14 @@ plot_AbanicoPlot <- function(
}
}

if(missing(summary) == TRUE) {
if(missing(summary))
summary <- c("n", "in.2s")
}

if(missing(summary.pos) == TRUE) {
if(missing(summary.pos))
summary.pos <- "sub"
}

if(missing(mtext) == TRUE) {
if(missing(mtext))
mtext <- ""
}

## create preliminary global data set
De.global <- data[[1]][,1]
Expand Down Expand Up @@ -1001,8 +995,8 @@ plot_AbanicoPlot <- function(
summary.col <- extraArgs$col
centrality.col <- extraArgs$col
} else {
bar.col <- layout$abanico$colour$bar.col
if(length(layout$abanico$colour$bar) == 1) {
bar.col <- layout$abanico$colour$bar.fill
if(length(layout$abanico$colour$bar.fill) == 1) {
bar.col <- 1:length(data)
}

Expand Down
7 changes: 6 additions & 1 deletion tests/testthat/test_plot_AbanicoPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,14 @@ test_that("Test examples from the example page", {
summary = c("n", "in.2s", "median")))

## create Abanico plot with predefined layout definition
expect_silent(plot_AbanicoPlot(data = ExampleData.DeValues,
layout <- expect_silent(plot_AbanicoPlot(data = ExampleData.DeValues,
layout = "journal"))

## trigger a few test cases related to layout
layout$abanico$colour$centrality <- 1:20
expect_silent(plot_AbanicoPlot(data = ExampleData.DeValues,
layout = "journal"))

## now with predefined layout definition and further modifications
expect_silent(plot_AbanicoPlot(data = data.3,
z.0 = "median",
Expand Down

0 comments on commit 635688d

Please sign in to comment.