legend_divergingBins: Create legend for diverging bins representing two parties.

View source: R/plotly.R

legend_divergingBinsR Documentation

Create legend for diverging bins representing two parties.

Description

Create legend for diverging bins representing two parties.

Usage

legend_divergingBins(list_pal, labels, title = NULL, width = 200)

Arguments

list_pal

a named list of equal-length color vectors. Each vector consists of color codes. And the name of the vector represents the party name.

labels

a character vector for labeling colors, should have the same length as any one color vector in 'list_pal'

title

title for the legend

Examples

colorspace::diverging_hcl(n = 10, h = c(245, 120), c = c(31, 100), l = c(30, 100), power = c(1, 1.3), register = "kmt-dpp") -> pal
list_pal = list(
  "國民黨"=rev(pal[1:5]),
  "民進黨"=pal[6:10]
)
labels=c("0-50","50-55","55-60","60-65","65-100%")

legend_divergingBins(list_pal, labels, title=NULL)

tpemartin/econIDV documentation built on July 2, 2023, 7:36 p.m.