简体   繁体   English

如何在R的传单中更改图例文本颜色?

[英]How to change legend text color in leaflet for R?

I created a leaflet map in R Shiny. 我在R Shiny中创建了一张传单地图。 The problem is that the legend text color is very bright. 问题在于图例文字颜色非常明亮。 I need to change the text color but don't find any option in leaflet legend for changing the legend text color. 我需要更改文本颜色,但在传单图例中找不到用于更改图例文本颜色的任何选项。 在此处输入图片说明

Nina! 妮娜!

As you can see from ?addLegend() , there are several parameters that may suit you: ?addLegend()可以看到,有几个参数可能适合您:

pal: the color palette function, generated from colorNumeric(), colorBin(), colorQuantile(), or colorFactor() pal:调色板函数,由colorNumeric(),colorBin(),colorQuantile()或colorFactor()生成

colors: a vector of (HTML) colors to be used in the legend if pal is not provided colors:如果未提供pal,则图例中将使用(HTML)颜色的向量

opacity: the opacity of colors 不透明度:颜色的不透明度

For example (from here: https://rstudio.github.io/leaflet/legends.html ): 例如(从此处: https : //rstudio.github.io/leaflet/legends.html ):

qpal <- colorQuantile("RdYlBu", your_dataset$your_variable, n = 5)

addLegend(pal = qpal, values = ~your_variable, opacity = 1)

Best! 最好!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM