I am using addLegend() in leaflet in R. My labels have minus signs in them. Is there an easy way to remove the dashes that come with numeric colour palettes to improve the formatting? labFormat doesn't seem to have such an option.
Asked
Active
Viewed 53 times
1 Answers
0
Can you take a look at addLegendNumeric
in the leaflegend
package ? It has the option to set tickWidth = 0
and tickLength=0
which make dashes (tickmarks) disappear.
You can read about leaflegend
here:
https://roh.engineering/posts/2021/02/introduction-to-leaflegend/
In the example for addLegendNumeric
the author didn't include these two parameters, but you can try them for yourself.
Example code:
library(leaflet)
data(quakes)
# Numeric Legend
numPal <- colorNumeric('viridis', quakes$depth)
leaflet() %>%
addTiles() %>%
addLegendNumeric(
pal = numPal,
values = quakes$depth,
position = 'topright',
tickLength = 0,
tickWidth = 0,
title = htmltools::tags$div('addLegendNumeric (Decreasing)',
style = 'font-size: 24px; text-align: center; margin-bottom: 5px;'),
orientation = 'vertical',
shape = 'stadium',
decreasing = TRUE,
height = 100,
width = 20,
bins = 4)

lpdoan
- 1
- 1