如何为 R 传单图例标题添加上标和下标。例如下面例子中的m2?
library(leaflet)
library(mapview) ## for the breweries dataset
## palette for the legend
palB <- colorNumeric('Blues', seq(1,14, by = 2))
##create a leaflet plot with legend
leaflet() %>%
addProviderTiles('CartoDB.Positron') %>%
addCircleMarkers(data = breweries, color = ~palB(number.of.types)) %>%
addLegend(pal = palB, values = breweries$number.of.types, title = "size (m2)")
我已经尝试过了
expression "'size'*' ('m'^2*')'"
但它只是打印出来
只需使用相应的 html 标签:
title = "size (m<sup>2</sup>)"
library(leaflet)
library(mapview) ## for the breweries dataset
## palette for the legend
palB <- colorNumeric('Blues', seq(1,14, by = 2))
##create a leaflet plot with legend
leaflet() %>%
addProviderTiles('CartoDB.Positron') %>%
addCircleMarkers(data = breweries, color = ~palB(number.of.types)) %>%
addLegend(pal = palB, values = breweries$number.of.types, title = "size (m<sup>2</sup>)")