Legend transparency for raster plots not working in version 4.0
Closed this issue · 3 comments
Hi @mtennekes I am migrating my code to tmap version 4.0 and notice that the legend transparency is not working. Here's a MWE.
# get one file for plotting
modis_file <- "https://www.dropbox.com/scl/fi/ykgw4envpvmlgcqee93gb/TERRA_MODIS_012010_NDVI_2013-09-14.jp2?rlkey=3tmm8w9u8m0mvnylrtddgh1k2&dl=1"
# read raster data as a stars object
st <- stars::read_stars(modis_file, along = "band", proxy = FALSE)
# scale the data
st <- st * 0.0001
p1 <- tmap::tm_shape(st, raster.downsample = FALSE) +
tmap::tm_raster(
col.scale = tm_scale_continuous(
values = "brewer.rd_yl_gn",
midpoint = NA),
col.legend = tm_legend(
title = "NDVI",
position = tm_pos_in("left", "bottom"),
frame = TRUE,
bg.color = "white",
bg.alpha = 0.8
)
) +
tmap::tm_graticules(labels.size = 0.7) +
tmap::tm_compass()
In the above code, the value of bg.alpha
makes no difference in the output.
Allow me to congratulate you for the excellent work on tmap
. Please also allow me a futher question. In version 3.3, the scale
parameter allowed general control over the plot output. What is the equivalent of scale
in version 4.0?
@mtennekes as preventive action, you can also take a look at https://github.com/r-devel/recheck and follow the step to run the action.
@gilbertocamara thanks for your input! bg.alpha
should be working now.
The scale parameter is working the same, e.g. ... + tm_layout(scale = 0.8)
. Somehow, it didn't work well with the legend, but now it does. Please check.
@mtennekes as preventive action, you can also take a look at https://github.com/r-devel/recheck and follow the step to run the action.
Thx for the tip. I am aware of these and similar automatic checks. We could do that later on.