topogram_legend: Legend for topogram widget

Description Usage Arguments Value Examples

View source: R/topo-extras.R

Description

Add a gradient legend in a topogram() widget.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
topogram_legend(
  topo,
  colors = NULL,
  labels = NULL,
  formatter = NULL,
  title = NULL,
  direction = c("h", "v"),
  height = "250px",
  width = "250px"
)

Arguments

topo

A topogram() / topogram_proxy() htmlwidget object.

colors

Vector of colors used in legend, default is to use colors used in topogram().

labels

Labels to display for values, default is to use range of values used in topogram().

formatter

Function to format labels, like scales::label_number().

title

Title for the legend.

direction

Direction: horizontal or vertical.

height, width

Height, width for legend. For gradient legend it represent the size of the dradient according to direction.

Value

A topogram() / topogram_proxy() htmlwidget object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(topogram)

topogram(world, value = "pop_est") %>% 
  topogram_legend(title = "Population")

topogram(world, value = "pop_est", palette = "Blues") %>% 
  topogram_legend(
    title = NULL,
    formatter = scales::label_comma(),
    direction = "v"
  )

dreamRs/topogRam documentation built on Dec. 16, 2021, 6:47 p.m.