Skip to content

Commit

Permalink
added message #879
Browse files Browse the repository at this point in the history
  • Loading branch information
mtennekes committed May 24, 2024
1 parent b86ecca commit ac80017
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
11 changes: 10 additions & 1 deletion R/messages.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,13 @@ message_nothing_to_show = function(any_groups) {
} else {
message("[nothing to show] no layers defined")
}
}
}

message_wrapstack = function(horizontal = TRUE) {
if (horizontal) {
message("[facets] use tm_facets_hstack() instead of tm_facets_wrap() to put the legends next to and aligned with the facets")
} else {
message("[facets] use tm_facets_vstack() instead of tm_facets_wrap() to put the legends next to and aligned with the facets")
}

}
16 changes: 11 additions & 5 deletions R/process_meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,17 @@ preprocess_meta = function(o, cdt) {


# in case there are per-facet legends but no no marginal legends, and nrows or ncols equals 1, place them outside (to do this, set them to all-facet here, change legend.position.all below accordingly, and finally determine legend position in step4_plot)
if (legend.present.auto[4] && (!any(legend.present.auto[2:3])) && (type == "stack")) {
per_facet_wrap_outside = TRUE
legend.present.auto[1] = TRUE
legend.present.auto[4] = FALSE
if (legend.present.auto[4] && (!any(legend.present.auto[2:3]))) {

if (type == "stack") {
legend.present.auto[1] = TRUE
legend.present.auto[4] = FALSE
set_to_stack_message = FALSE
} else {
set_to_stack_message = TRUE
}
} else {
per_facet_wrap_outside = FALSE
set_to_stack_message = FALSE
}


Expand Down Expand Up @@ -510,6 +515,7 @@ process_meta = function(o, d, cdt, aux) {

nrows = ceiling(n / ncols)
}
if ((nrows == 1 || ncols == 1) && set_to_stack_message) message_wrapstack(nrows == 1)
}

#overall scale down factor for facets
Expand Down
2 changes: 1 addition & 1 deletion R/step4_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ step4_plot = function(tm, vp, return.asp, show, knit, args) {
aux = tm$aux
cmp = tm$cmp

if ("bbx" %in% names(tmx[[o$main]])) {
if (length(tmx) && ("bbx" %in% names(tmx[[o$main]]))) {
bbm = tmx[[o$main]]$bbx
} else {
bbm = NULL
Expand Down

0 comments on commit ac80017

Please sign in to comment.