## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>") ## ----setup-------------------------------------------------------------------- library(orbis) ## ----------------------------------------------------------------------------- p <- orb(mtcars, x = wt, y = mpg, colour = hp, size = disp) + orb_points() + orb_labs(title = "Fuel economy", x = "Weight (1000 lbs)", y = "Miles per gallon", colour = "Horsepower") p ## ----------------------------------------------------------------------------- orb(mtcars, x = wt, y = mpg, colour = factor(cyl)) + orb_points() + orb_theme_dark() ## ----------------------------------------------------------------------------- set.seed(1) df <- data.frame(t = 1:80, v = cumsum(rnorm(80, 0.05))) orb(df, x = t, y = v) + orb_area(alpha = 0.3) + orb_line(width = 2, smooth = TRUE) + orb_labs(title = "A smoothed series") ## ----------------------------------------------------------------------------- counts <- data.frame(g = c("alpha", "beta", "gamma", "delta"), v = c(23, 41, 17, 35)) orb(counts, x = g, y = v, fill = g) + orb_bars() + orb_options(legend = FALSE, grid = "y") + orb_theme_ink() ## ----------------------------------------------------------------------------- orb(mtcars, x = wt, y = mpg, colour = hp) + orb_points() + orb_facet(cyl) + orb_labs(title = "By cylinder count", x = "Weight", y = "MPG") ## ----------------------------------------------------------------------------- set.seed(3) d <- data.frame(t = rep(1:40, 3), v = c(cumsum(rnorm(40)), cumsum(rnorm(40, 0.3)), cumsum(rnorm(40, -0.2))), region = rep(c("north", "south", "east"), each = 40)) orb(d, x = t, y = v) + orb_area(alpha = 0.3) + orb_line() + orb_facet(region, ncol = 3, scales = "free_y") ## ----------------------------------------------------------------------------- orb(mtcars, x = wt, y = mpg, colour = hp) + orb_points() + orb_scale_colour("magma", reverse = TRUE) + orb_scale_size(range = c(3, 16)) + orb_scale_y(limits = c(10, 35)) ## ----------------------------------------------------------------------------- orb_palettes() ## ----------------------------------------------------------------------------- str(world_map) ## ----------------------------------------------------------------------------- vals <- data.frame(region = c("Brazil", "India", "France", "China", "Nigeria"), v = c(3, 9, 5, 8, 6)) orb_worldmap(values = vals, value_col = "v", projection = "robinson") + orb_labs(title = "A small choropleth") ## ----------------------------------------------------------------------------- orb_worldmap(values = vals, value_col = "v", projection = "equalearth", palette = "ice") + orb_labs(title = "Equal Earth") ## ----------------------------------------------------------------------------- orb_worldmap(projection = "orthographic", ocean = "#0B1F33") + orb_coord_map("orthographic", centre = c(20, 15)) + orb_theme_dark() ## ----------------------------------------------------------------------------- cities <- data.frame( long = c(2.35, -74.0, 151.2, 77.2, -43.2), lat = c(48.86, 40.7, -33.87, 28.6, -22.9), pop = c(11, 19, 5, 32, 13) ) orb(cities, x = long, y = lat, size = pop) + orb_map(fill = "#E9ECEF") + orb_geo_points(colour = "#F76707") + orb_coord_map("robinson") + orb_labs(title = "Cities") ## ----eval = FALSE------------------------------------------------------------- # orb_save(p, "figure.png", dpi = 600) # high-resolution raster for print # orb_save(p, "figure.pdf") # vector # orb_save(p, "figure.svg") # vector, still interactive # orb_save(p, "figure.html") # self-contained interactive page # orb_interactive(p) # open in the viewer