diff --git a/DESCRIPTION b/DESCRIPTION index 27e765f5..1c69ae3c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: tinyplot Type: Package Title: Lightweight Extension of the Base R Graphics System -Version: 0.5.0 +Version: 0.5.0.99 Date: 2025-09-21 Authors@R: c( diff --git a/NEWS.md b/NEWS.md index b8f2c63a..17b02e75 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,15 @@ _If you are viewing this file on CRAN, please check the [latest NEWS](https://grantmcdermott.com/tinyplot/NEWS.html) on our website where the formatting is also better._ +## Dev version + +### Bug fixes + +- For bubble plots, we now drop the minimum legend category (label) if it is + equal to 0. The previous behaviour was just an artifact of the `pretty` breaks + algorithm that we use to create discrete legend categories. The interior plot + elements, e.g. bubble points, are unaffected. (#498 @grantmcdermott) + ## 0.5.0 ### New features diff --git a/R/type_points.R b/R/type_points.R index 8b18a516..6ed592d8 100644 --- a/R/type_points.R +++ b/R/type_points.R @@ -72,6 +72,11 @@ data_points = function(clim = c(0.5, 2.5)) { cex = rescale_num(sqrt(c(bubble_labs, cex))/pi, to = clim) bubble_cex = cex[1:len_labs] cex = cex[(len_labs+1):length(cex)] + # catch for cases where pretty breaks leads to smallest category of 0 + if (bubble_labs[1] == 0) { + bubble_labs = bubble_labs[-1] + bubble_cex = bubble_cex[-1] + } names(bubble_cex) = format(bubble_labs) if (max(clim) > 2.5) { legend_args[["x.intersp"]] = max(clim) / 2.5 diff --git a/R/type_text.R b/R/type_text.R index a34d4b11..dca76325 100644 --- a/R/type_text.R +++ b/R/type_text.R @@ -66,6 +66,11 @@ data_text = function(labels, clim = c(0.5, 2.5)) { cex = rescale_num(sqrt(c(bubble_labs, cex)) / pi, to = clim) bubble_cex = cex[1:len_labs] cex = cex[(len_labs + 1):length(cex)] + # catch for cases where pretty breaks leads to smallest category of 0 + if (bubble_labs[1] == 0) { + bubble_labs = bubble_labs[-1] + bubble_cex = bubble_cex[-1] + } names(bubble_cex) = format(bubble_labs) if (max(clim) > 2.5) { legend_args[["x.intersp"]] = max(clim) / 2.5 diff --git a/inst/tinytest/_tinysnapshot/bubble_dual_continuous.svg b/inst/tinytest/_tinysnapshot/bubble_dual_continuous.svg index ea394222..67f9d883 100644 --- a/inst/tinytest/_tinysnapshot/bubble_dual_continuous.svg +++ b/inst/tinytest/_tinysnapshot/bubble_dual_continuous.svg @@ -26,15 +26,6 @@ - - - - - - - - - 2.0 2.5 @@ -47,19 +38,17 @@ - - - - Sepal.Width - - - - - - + + + + + iris$Petal.Width -0.0 -0.5 -1.0 -1.5 -2.0 -2.5 +0.5 +1.0 +1.5 +2.0 +2.5 diff --git a/inst/tinytest/_tinysnapshot/bubble_dual_discrete.svg b/inst/tinytest/_tinysnapshot/bubble_dual_discrete.svg index fd762626..585b79a8 100644 --- a/inst/tinytest/_tinysnapshot/bubble_dual_discrete.svg +++ b/inst/tinytest/_tinysnapshot/bubble_dual_discrete.svg @@ -26,15 +26,6 @@ - - - - - - - - - @@ -42,19 +33,17 @@ setosa versicolor virginica - - - - - - + + + + + iris$Petal.Width -0.0 -0.5 -1.0 -1.5 -2.0 -2.5 +0.5 +1.0 +1.5 +2.0 +2.5 diff --git a/inst/tinytest/_tinysnapshot/bubble_dual_fancy.svg b/inst/tinytest/_tinysnapshot/bubble_dual_fancy.svg index 2bf07612..87271da7 100644 --- a/inst/tinytest/_tinysnapshot/bubble_dual_fancy.svg +++ b/inst/tinytest/_tinysnapshot/bubble_dual_fancy.svg @@ -26,40 +26,29 @@ - - - - - - - - - - - 2.0 - 2.5 - 3.0 - 3.5 - 4.0 -- - -- - -- - -- - -- - -Sepal.Width - - - - - - -iris$Petal.Width -0.0 -0.5 -1.0 -1.5 -2.0 -2.5 + + 2.0 + 2.5 + 3.0 + 3.5 + 4.0 +- - +- - +- - +- - +- - +Sepal.Width + + + + + +iris$Petal.Width +0.5 +1.0 +1.5 +2.0 +2.5 diff --git a/inst/tinytest/_tinysnapshot/bubble_simple.svg b/inst/tinytest/_tinysnapshot/bubble_simple.svg index b0ea4936..21939ce5 100644 --- a/inst/tinytest/_tinysnapshot/bubble_simple.svg +++ b/inst/tinytest/_tinysnapshot/bubble_simple.svg @@ -26,19 +26,17 @@ - - - - - - -iris$Petal.Width -0.0 -0.5 -1.0 -1.5 -2.0 -2.5 + + + + + +iris$Petal.Width +0.5 +1.0 +1.5 +2.0 +2.5 diff --git a/inst/tinytest/_tinysnapshot/bubble_simple_bottom.svg b/inst/tinytest/_tinysnapshot/bubble_simple_bottom.svg index 7219735b..349dcecb 100644 --- a/inst/tinytest/_tinysnapshot/bubble_simple_bottom.svg +++ b/inst/tinytest/_tinysnapshot/bubble_simple_bottom.svg @@ -26,19 +26,17 @@ - - - - - - + + + + + iris$Petal.Width -0.0 -0.5 -1.0 -1.5 -2.0 -2.5 +0.5 +1.0 +1.5 +2.0 +2.5 diff --git a/inst/tinytest/_tinysnapshot/bubble_simple_clim.svg b/inst/tinytest/_tinysnapshot/bubble_simple_clim.svg index a4b39e67..f0bea58d 100644 --- a/inst/tinytest/_tinysnapshot/bubble_simple_clim.svg +++ b/inst/tinytest/_tinysnapshot/bubble_simple_clim.svg @@ -26,19 +26,17 @@ - - - - - - -iris$Petal.Width -0.0 -0.5 -1.0 -1.5 -2.0 -2.5 + + + + + +iris$Petal.Width +0.5 +1.0 +1.5 +2.0 +2.5