Visualizing Social Science Data with 'ggplot2'

A 'ggplot2' extension for implementing parliament charts and several other useful visualizations.


Build Status CRAN_Release_Badge CRAN_Download_Badge 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()

Parliament Diagram

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()

Hybrid Boxplot

Roadmap

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

News

ggpol 0.0.4

Minor changes

  • StatBoxJitter now inherits from StatBoxplot rather than Stat, making for slimmer bars.
  • geom_boxjitter() does not require x argument anymore.
  • Added import of ggplot2::resolution(), ggplot2::alpha(), ggplot2::position_dodge2() and ggplot2:PositionJitter to geom_boxjitter(). (#2)
  • Added import of ggplot2::.pt to geom_bartext().
  • Added import of ``grid::unit(),ggplot2::zeroGrob()andggplot2::render_axes()tofacet_share()`.

ggpol 0.0.3

Minor changes

  • facet_share fixed for ggplot version 3.0.0.

ggpol 0.0.2

New features

  • geom_bartext for otherwise overlapping bar chart labels

Minor changes

  • facet_share axis spacing has been fixed for vertical direction

ggpol 0.0.1

Major changes

  • First commit

New features

  • facet_share for two plots sharing an axis
  • geom_arcbar for arc bar diagrams with optional spacing
  • geom_boxjitter for hybrid boxplots with optional errorbars
  • geom_circle for circles with given radius
  • geom_parliament for parliament diagrams
  • geom_tshighlight for timeseries highlighting

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("ggpol")

0.0.4 by Frederik Tiedemann, 4 months ago


https://github.com/erocoar/ggpol


Browse source code at https://github.com/cran/ggpol


Authors: Frederik Tiedemann [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports grid, gtable, grDevices, plyr, rlang, dplyr

Depends on ggplot2

Suggests knitr, rmarkdown


Suggested by afex.


See at CRAN