All Projects → hrbrmstr → Worldtilegrid

hrbrmstr / Worldtilegrid

Licence: other
🔲🗺 World Tile Grid Geom for ggplot2 [WIP]

Programming Languages

r
7636 projects

Labels

Projects that are alternatives of or similar to Worldtilegrid

Geowaffle
Combining waffle plot with geofacet
Stars: ✭ 26 (-25.71%)
Mutual labels:  rstats
Originr
Species origin data from the web in R
Stars: ✭ 13 (-62.86%)
Mutual labels:  rstats
Onnx R
R Interface to Open Neural Network Exchange (ONNX)
Stars: ✭ 31 (-11.43%)
Mutual labels:  rstats
Rnaturalearthdata
to hold data used by rnaturalearth
Stars: ✭ 8 (-77.14%)
Mutual labels:  rstats
Ggrepel
📍 Repel overlapping text labels away from each other.
Stars: ✭ 853 (+2337.14%)
Mutual labels:  rstats
Wellknown
WKT <-> GeoJSON
Stars: ✭ 15 (-57.14%)
Mutual labels:  rstats
Goodshirt
R client to the Good Place Quotes API
Stars: ✭ 24 (-31.43%)
Mutual labels:  rstats
Ggcats
The geom you always wished for adding cats to ggplot2
Stars: ✭ 34 (-2.86%)
Mutual labels:  rstats
Ieeer
Search IEEE publications in R
Stars: ✭ 12 (-65.71%)
Mutual labels:  rstats
Sofa
easy R interface to CouchDB
Stars: ✭ 30 (-14.29%)
Mutual labels:  rstats
Spenv
Combine environmental and spatial data
Stars: ✭ 8 (-77.14%)
Mutual labels:  rstats
Newsfreq
R package to search for keyword frequencies in news articles via newsfreq.com
Stars: ✭ 9 (-74.29%)
Mutual labels:  rstats
Crafter
🔬 An R package to work with PCAPs
Stars: ✭ 27 (-22.86%)
Mutual labels:  rstats
Rmarkdown Website Tutorial
Tutorial for creating websites w/ R Markdown
Stars: ✭ 26 (-25.71%)
Mutual labels:  rstats
Graphql
Bindings to libgraphqlparser for R
Stars: ✭ 31 (-11.43%)
Mutual labels:  rstats
Tidymv
Tidy Model Visualisation for Generalised Additive Models
Stars: ✭ 25 (-28.57%)
Mutual labels:  rstats
R Style Guide
Best practices for readable, sharable, and verifiable R code
Stars: ✭ 15 (-57.14%)
Mutual labels:  rstats
Cld2
R Wrapper for Google's Compact Language Detector 2
Stars: ✭ 34 (-2.86%)
Mutual labels:  rstats
Rstudioconf tweets
🖥 A repository for tracking tweets about rstudio::conf
Stars: ✭ 32 (-8.57%)
Mutual labels:  rstats
Longurl
ℹ️ Small R package for no-API-required URL expansion
Stars: ✭ 30 (-14.29%)
Mutual labels:  rstats

Travis-CI Build Status Coverage Status CRAN_Status_Badge

worldtilegrid

A ggplot2 Geom for World Tile Grids

Description

A “tile grid map” is a cartogram that uses same-sized tiles in approximate, relative positions of each other to represent a world map. The world tile grid relative position reference system used by this ‘ggplot2’ ‘Geom/Stat’ was the original work of ‘Jon Schwabish’ and converted to ‘CSV’ by ‘Maarten Lambrechts’.

What’s Inside The Tin

The following functions are implemented:

  • geom_wtg: World Tile Grid Geom
  • theme_enhance_wtg: World tile grid theme cruft remover that can be used with any other theme
  • wtg: World Tile Grid Basemap Data

The following data is included/exported:

wtg: World Tile Grid Basemap Data

Installation

install.packages("worldtilegrid", repos = "https://cinc.rud.is")
# or
devtools::install_git("https://git.rud.is/hrbrmstr/worldtilegrid.git")
# or
devtools::install_git("https://git.sr.ht/~hrbrmstr/worldtilegrid")
# or
devtools::install_gitlab("hrbrmstr/worldtilegrid")
# or
devtools::install_bitbucket("hrbrmstr/worldtilegrid")
# or
devtools::install_github("hrbrmstr/worldtilegrid")

Usage

library(worldtilegrid)
library(tidyverse)

# current verison
packageVersion("worldtilegrid")
## [1] '0.2.0'

Example (All countries are in the data set)

iso3cs <- worldtilegrid::wtg$alpha.3

set.seed(1)
data_frame(
  ctry = iso3cs,
  `Thing Val` = sample(1000, length(ctry))
) -> xdf

ggplot(xdf, aes(country = ctry, fill = `Thing Val`)) +
  geom_wtg(border_size = 0.5, border_col = "#252a32") +
  geom_text(
    aes(
      label = stat(alpha.2), 
      colour = I(ifelse(`Thing Val` < 500, "white", "black"))
    ), 
    stat = "wtg", size = 2
  ) + 
  coord_equal() +
  viridis::scale_fill_viridis() +
  labs(title = "World Tile Grid") +
  hrbrthemes::theme_ft_rc() +
  theme_enhance_wtg()

Example (Only a few countries are in the data set)

set.seed(1)
data_frame(
  ctry = worldtilegrid::wtg$alpha.3[1:30],
  `Thing Val` = sample(1000, length(ctry))
) -> xdf

ggplot(xdf, aes(country = ctry, fill = `Thing Val`)) +
  geom_wtg() +
  geom_text(
    aes(
      label = stat(alpha.2),
      colour = I(ifelse(`Thing Val` < 400, "#b2b2b2", "#2b2b2b"))
    ), 
    stat="wtg", size=2
  ) + 
  coord_equal() +
  viridis::scale_fill_viridis() +
  labs(title = "World Tile Grid") +
  hrbrthemes::theme_ft_rc() +
  theme_enhance_wtg()

Facet Example (All countries are in the data set)

set.seed(1)
data_frame(
  ctry = worldtilegrid::wtg$alpha.3,
  `Thing Val` = sample(1000, length(ctry)),
  grp = 'Thing One'
) -> xdf1

data_frame(
  ctry = worldtilegrid::wtg$alpha.3,
  `Thing Val` = sample(1000, length(ctry)),
  grp = 'Thing Two'
) -> xdf2

bind_rows(
  xdf1,
  xdf2
) -> xdf

ggplot(xdf, aes(country = ctry, fill = `Thing Val`)) +
  geom_wtg() +
  coord_equal() +
  facet_wrap(~grp) +
  viridis::scale_fill_viridis() +
  labs(title = "World Tile Grid Facets") +
  hrbrthemes::theme_ft_rc() +
  theme_enhance_wtg()

Facet Example (Only a few countries are in the data set)

The geom will fill in the gaps for you:

set.seed(1)
tibble(
  ctry = sample(iso3cs, 40),
  `Thing Val` = sample(1000, length(ctry)),
  grp = 'Thing One'
) -> xdf1

tibble(
  ctry = sample(iso3cs, 40),
  `Thing Val` = sample(1000, length(ctry)),
  grp = 'Thing Two'
) -> xdf2

bind_rows(
  xdf1,
  xdf2
) -> xdf

ggplot(xdf, aes(country = ctry, fill = `Thing Val`)) +
  geom_wtg(border_size = 0.5) +
  coord_equal() +
  facet_wrap(~grp) +
  scale_fill_viridis_c(
    na.value = alpha(hrbrthemes::ft_cols$gray, 2/5), direction = -1,
    option = "magma"
  ) +
  guides(
    fill = guide_colourbar(title.position = "top", title.hjust = 0.5)
  ) +
  labs(title = "World Tile Grid Facets") +
  hrbrthemes::theme_ipsum_rc() +
  theme_enhance_wtg() +
  theme(legend.position = "bottom") +
  theme(legend.key.width = unit(2, "lines"))
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].