Skip to content

Commit

Permalink
add iName labelling to plot_framework
Browse files Browse the repository at this point in the history
  • Loading branch information
bluefoxr committed Aug 26, 2024
1 parent 6074772 commit ba09bf8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Encoding: UTF-8
URL: https://bluefoxr.github.io/COINr/
BugReports: https://github.com/bluefoxr/COINr/issues
LazyData: true
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
Imports:
openxlsx (>= 4.2.3),
stats,
Expand Down
10 changes: 8 additions & 2 deletions R/plot_framework.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#' @param text_colour Colour of label text - default `"white"`.
#' @param text_size Text size of labels, default 2.5
#' @param transparency If `TRUE`, levels below `colour_level` are differentiated with some transparency.
#' @param text_label Text labelling of segments: either `"iCode"` or `"iName"`
#'
#' @importFrom rlang .data
#'
Expand All @@ -38,7 +39,8 @@
#' @return A ggplot2 plot object
#' @export
plot_framework <- function(coin, type = "sunburst", colour_level = NULL,
text_colour = NULL, text_size = NULL, transparency = TRUE){
text_colour = NULL, text_size = NULL, transparency = TRUE,
text_label = "iCode"){

# CHECKS ------------------------------------------------------------------

Expand All @@ -49,6 +51,10 @@ plot_framework <- function(coin, type = "sunburst", colour_level = NULL,
iMeta <- coin$Meta$Ind[!is.na(coin$Meta$Ind$Level), ]
maxlev <- coin$Meta$maxlev

if(text_label %nin% c("iCode", "iName")){
stop("text_label must be either 'iCode' or 'iName'")
}

# DEFAULTS ----------------------------------------------------------------

text_colour <- set_default(text_colour, "white")
Expand Down Expand Up @@ -116,7 +122,7 @@ plot_framework <- function(coin, type = "sunburst", colour_level = NULL,
plt <- ggplot2::ggplot(iMeta, ggplot2::aes(x = .data$Level,
y = .data$EffWeight,
fill = .data$colourcol,
label = .data$iCode))
label = .data[[text_label]]))

# bars
if(transparency){
Expand Down
5 changes: 4 additions & 1 deletion man/plot_framework.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ba09bf8

Please sign in to comment.