Learn R Programming

⚠️There's a newer version (0.0.7) of this package.Take me there.

About

ggpol adds parliament diagrams and various other visualizations and convenience functions to ggplot2.

Installation

ggpol can be installed via GitHub:

if (!require(devtools)) {
    install.packages('devtools')
}
devtools::install_github('erocoar/ggpol')

Selected Features

Below are two functions added by ggpol. For a full overview with applications, please refer to the vignette.

geom_parliament draws a parliament diagram, clustering points along an arc by parties with each point representing a single member of parliament.

bt <- data.frame(
 parties = factor(c("CDU", "CSU", "AfD", "FDP", "SPD", 
                    "Linke", "Gruene", "Fraktionslos"),
                  levels = c("CDU", "CSU", "AfD", "FDP", "SPD", 
                             "Linke", "Gruene", "Fraktionslos")),
 seats   = c(200, 46, 92, 80, 153, 69, 67, 2),
 colors  = c("black", "blue", "lightblue", "yellow", 
             "red","purple", "green", "grey"),
 stringsAsFactors = FALSE)

ggplot(bt) + 
  geom_parliament(aes(seats = seats, fill = parties), color = "black") + 
  scale_fill_manual(values = bt$colors, labels = bt$parties) +
  coord_fixed() + 
  theme_void()

geom_boxjitter produces a hybrid of box- and scatterplot.

df <- data.frame(score = rgamma(150, 4, 1), 
                 gender = sample(c("M", "F"), 150, replace = TRUE), 
                genotype = factor(sample(1:3, 150, replace = TRUE)))

ggplot(df) + geom_boxjitter(aes(x = genotype, y = score, fill = gender),
                            jitter.shape = 21, jitter.color = NA, 
                            jitter.height = 0, jitter.width = 0.04,
                            outlier.color = NA, errorbar.draw = TRUE) +
  scale_fill_manual(values = c("#ecb21e", "#812e91")) +
  theme_minimal()

Roadmap

If you would like to see a certain feature, please file an issue with a detailed description.

Copy Link

Version

Install

install.packages('ggpol')

Monthly Downloads

1,434

Version

0.0.5

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Last Published

March 14th, 2019

Functions in ggpol (0.0.5)

geom_boxjitter

A hybrid boxplot.
geom_parliament

Create a Parliament Diagram
geom_tshighlight

Timeseries highlighting
FacetShare

ggplot extensions
geom_arcbar

Create an Arc-Barchart
geom_bartext

Repelling text for GeomBar.
GeomConfmat

Confusion Matrix
facet_share

A shared axis for two panels
geom_circle

Circles with pre-defined radii.