Utilities for common R visualization tasks at WSP Finland. Current features:
Planned features:
ggplot2
themes for WSP and other common contextsEnsure you have devtools
installed. To get the latest development version of wspviz
, run the following command:
devtools::install_github("webbidevaajat/wspviz")
Current version depends on ggplot2
library (because of show_palettes()
function).
pal_wsp()
: standard WSP colorspal_wsp2()
: strong WSP colors + some ad-hoc accent colors, meant for visualizations where several distinct colors are neededpal_hsl()
: color palette defined by Helsinki Region Transport style guideGet all the HSL colors as a named vector:
library(wspviz)
pal_hsl()
#> bus tram metro train ferry bike
#> "#007ac9" "#00985f" "#ff6319" "#8c4799" "#00b9e4" "#fcb919"
#> lightrail lightblue pink lightpink green lightgreen
#> "#00b2a9" "#bee4f8" "#f092cd" "#f4deec" "#64be1e" "#d0e6be"
#> red yellow gray1 gray2 gray3 gray4
#> "#dc0451" "#fed100" "#333333" "#636363" "#999999" "#dddddd"
Get selected WSP colors:
library(wspviz)
pal_wsp("red", "blue", "gray")
#> red blue gray
#> "#f9423a" "#859fbb" "#757679"
Plot a color palette:
library(wspviz)
show_palette(pal_wsp())
NEW: a palette with basic WSP colors + a couple of roughly matching accent colors:
library(wspviz)
show_palette(pal_wsp2())
If you are for some reason running the palette functions several times, say, generating 1000 different plots, you can extract the color codes and just use named vector subsetting for a slight performance benefit (comparison has not been made so far), like this:
library(wspviz)
pal <- pal_hsl()
show_palette(pal[c("bus", "tram", "train", "metro", "ferry")])
# Instead of show_palette(pal_wsp("purple", "midnightblue"))
If you have any ideas or questions, feel free to submit an issue or even make a pull request!
Arttu Kosonen (datarttu), arttu (dot) kosonen (at) wsp (dot) com
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.