编辑leaftlet labelFormat的源代码以编辑打断/记号标记

编辑leaftlet labelFormat的源代码以编辑打断/记号标记,r,colors,formatting,leaflet,legend,R,Colors,Formatting,Leaflet,Legend,我正在尝试编辑传单图例。是否有人知道在使用labelFormat中的colorNumeric(非colorQuantile,请参阅)中的预定义调色板时,如何编辑中断的数量以及在何处放置记号标记?这是我得到的图例(代码如下): 正如您所看到的,这是一个高度扭曲的图例,如果断点位于c(1,3,6,9)或类似的位置,可以轻松编辑,包括限制,则更有意义 您可以包括箱子,但根据文件,这些箱子的间距将相等: 从这个角度看,你似乎可以用colorQuantile来做,但这不是我想要的。我想我可能需要像这样

我正在尝试编辑
传单
图例。是否有人知道在使用
labelFormat
中的
colorNumeric
(非
colorQuantile
,请参阅)中的预定义调色板时,如何编辑
中断的数量以及在何处放置
记号标记
?这是我得到的图例(代码如下):

正如您所看到的,这是一个高度扭曲的图例,如果断点位于
c(1,3,6,9)
或类似的位置,可以轻松编辑,包括限制,则更有意义

您可以包括
箱子
,但根据文件,这些箱子的间距将相等:

从这个角度看,你似乎可以用
colorQuantile
来做,但这不是我想要的。我想我可能需要像这样浏览源代码,但我看不到我可以在哪里编辑
中断
或勾号

可复制的代码如下所示:

#下面是我的另一个问题:
#https://stackoverflow.com/questions/60321495/merging-palettes-with-colorramppalette-and-plotting-with-leaflet/
图书馆(单张)
图书馆(tidyverse)
种子(8)
df%
变异(排名=1:n())
门槛
#following my other question:
#https://stackoverflow.com/questions/60321495/merging-palettes-with-colorramppalette-and-plotting-with-leaflet/
library(leaflet)
library(tidyverse)

set.seed(8)
df <- data.frame(var = rnorm(100)^2)
df <- df %>% 
  arrange(var) %>% 
  mutate(ranking = 1:n()) 
threshold <- sum(df$var < 1)   
 # number of values below threshold 
threshold #= 67

### Create an asymmetric color range
## Make vector of colors for values smaller than 1 
rc1 <- colorRampPalette(colors = c("#006837", "#1A9850"), space = "Lab")(threshold)    

## Make vector of colors for values larger than 1
rc2 <- colorRampPalette(colors = c("#FDAE61", "#A50026"), space = "Lab")(length(df$var) - threshold)

## Combine the two color palettes
rampcols <- c(rc1, rc2)

# Create a palette for a legend with ranking again. But this time with
# colorNumeric()

mypal2 <- colorNumeric(palette = rampcols, domain = df$ranking)

leaflet() %>% 
  addLegend(pal = mypal2, values = df$ranking,
            #bins = 10,
            labFormat = labelFormat(transform = function(x) df$var[x]))