Skip to content

Commit cec100d

Browse files
committed
1 parent f300a2f commit cec100d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

R/tmapGridComp_funs.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ tmapGridCompPlot.tm_scalebar = function(comp, o, fH, fW) {
449449
sel = which(ticks3 <= sbW)
450450

451451
if (!is.null(comp$breaks) && length(sel) != length(ticks3)) {
452-
warning("Not all scale bar breaks could be plotted. Try increasing the scale bar width or descreasing the font size", call. = FALSE)
452+
cli::cli_warn("{.field tm_scalebar} Not all scale bar breaks could be plotted. Try increasing the scale bar width or decreasing the font size")
453453
}
454454

455455
ticks3 = ticks3[sel]
@@ -464,7 +464,12 @@ tmapGridCompPlot.tm_scalebar = function(comp, o, fH, fW) {
464464

465465
n = length(ticks2)
466466

467-
widths = ticks3[2:n] - ticks3[1:(n-1)]
467+
if (length(ticks3) == 1) {
468+
cli::cli_warn("{.field tm_scalebar} Only one scale bar break could be plotted. Try decreasing the font size or increasing the scale bar width")
469+
widths = sbW
470+
} else {
471+
widths = ticks3[2:n] - ticks3[1:(n-1)]
472+
}
468473
size = min(comp$text.size, widths/max(ticksWidths))
469474
x = ticks3[1:(n-1)] + ticksWidths[1]*size #+ .5*widths[1]
470475

0 commit comments

Comments
 (0)