带有分组值字幕的传单图例

发布于 2025-01-21 02:18:43 字数 1925 浏览 3 评论 0原文

有没有办法为传单图例添加字幕?以下示例生成一个正常运行的图例。但是,有没有办法将子组组合到同一个图例中?

我可以想象这可以通过通过 className 参数(默认 className = "info legend")向图例注入自定义 CSS 代码来解决。但我对 CSS 完全是个新手。 https://www.rdocumentation.org/packages/leaflet/ versions/2.1.1/topics/addLegend

这项工作也很有帮助,它是为了 NA 级的间距而完成的(https://github.com/rstudio/leaflet/issues/615#issuecomment-656035992< /a>)

为了说明我想要的内容,我创建了不同的图例条目,但它们没有正确连接。

library(leaflet)
colors <- colorFactor(palette="viridis",
                      domain=gadmCHE@data$NAME_1, na.color="transparent")

Deutsch <- gadmCHE[c(1:6,9:12,14:20,22,25:26),]
Italienisch <- gadmCHE[c(21),]
Französisch <- gadmCHE[-c(1:6,9:12,14:22,25:26),]

gadmCHE %>% leaflet() %>% addTiles() %>% 
  addPolygons(fillColor = ~colors(NAME_1), fillOpacity = 1) %>%
  addLegend(position = "topright", pal = colors, values = Deutsch@data$NAME_1, title = "Deutsch")%>%
  addLegend(position = "topright", pal = colors, values = Italienisch@data$NAME_1, title = "Italiensch")%>%
  addLegend(position = "topright", pal = colors, values = Französisch@data$NAME_1, title = "Französisch")

稍微多一点复杂的情节

我实际上需要复制以下内容。请耐心等待,因为

  • 我知道缩短图例条目会更好,但这会带来相当多的遗产。我不太可能在这方面取得成功。

  • 将各州归为不同语言区域的说法不正确。

  • 这并不完全是我想要展示的,因为在我的例子中,整个图例条目不能变得更短(即,Senkrecht durchwaschene Böden,Normal durchlässig,sehr tiefgründig)

在此处输入图像描述

Is there a way to add subtitles to leaflet legends? The following example produces a functioning legend. However, is there a way to combine the subgroups to the same legend?

I could imagine this could be solved by injecting custom CSS-code to the legend by the className parameter (default className = "info legend"). But I'm a complete novice to CSS.
https://www.rdocumentation.org/packages/leaflet/versions/2.1.1/topics/addLegend

Helpful might as well be this work, done for the spacing to the NA-class (https://github.com/rstudio/leaflet/issues/615#issuecomment-656035992)

To illustrate what I would like to have I created different legend entries, but they are not properly connected.

library(leaflet)
colors <- colorFactor(palette="viridis",
                      domain=gadmCHE@data$NAME_1, na.color="transparent")

Deutsch <- gadmCHE[c(1:6,9:12,14:20,22,25:26),]
Italienisch <- gadmCHE[c(21),]
Französisch <- gadmCHE[-c(1:6,9:12,14:22,25:26),]

gadmCHE %>% leaflet() %>% addTiles() %>% 
  addPolygons(fillColor = ~colors(NAME_1), fillOpacity = 1) %>%
  addLegend(position = "topright", pal = colors, values = Deutsch@data$NAME_1, title = "Deutsch")%>%
  addLegend(position = "topright", pal = colors, values = Italienisch@data$NAME_1, title = "Italiensch")%>%
  addLegend(position = "topright", pal = colors, values = Französisch@data$NAME_1, title = "Französisch")

slightly more complex plot

I actually would need to replicate the following. Please bear with me as

  • I'm aware it would be better to shorten the legend entries, but that has quite some legacy attached to it. It is unlikely I'll be successful on that.

  • The attribution of the Cantons to different language regions is not... correct.

  • It further is not exactly what I would like to show, as in my case, the whole legend entry cannot be made shorter (i.e. a, Senkrecht durchwaschene Böden, Normal durchlässig, sehr tiefgründig)

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文