本文介绍了传单图例名称为两行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将图例的名称放在两行中,但通常的方法不起作用。你能帮我找出原因吗?
library(leaflet)
dfXL = data.frame(
lat = as.numeric(c("-30","-30.1","-30.5")),
lng = as.numeric(c("14","14.6","14.6")),
sizeXL = as.numeric(c("1","2","3")),
color = "red")
#dfXL
palXL <- colorNumeric(palette=c("#FFFFFF","#FFA07A"), as.numeric(as.character(dfXL$sizeXL)))
dfXL$size_color<- palXL(dfXL$sizeXL)
dfXL
XL = leaflet(dfXL)%>%
setView(lng = 10.132974, lat = 10.706839, zoom = 3) %>%
addProviderTiles("Esri.WorldImagery") %>%
addCircleMarkers(radius = ~sizeXL/25 , color = ~size_color, fill = F,clusterOptions = markerClusterOptions(freezeAtZoom = 16),opacity=1) %>%
addLegend("bottomright",labels=dfXL$sizeXL,title=paste(expression(atop("a","b"))),opacity=1,colors=dfXL$size_color)
XL
推荐答案
使用</br>
引入中断
复制并粘贴此可复制的示例:
library(leaflet)
library(raster)
p <- shapefile(system.file("external/lux.shp", package="raster"))
pal <- colorNumeric(
palette = "Reds",
domain = p$AREA)
p %>%
leaflet() %>%
addTiles() %>%
addPolygons(stroke=FALSE, color = ~pal(AREA), fillOpacity = 1) %>%
addLegend(pal = pal, values = ~AREA, title = "line 1 </br> line 2")
这篇关于传单图例名称为两行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!