Simpler Appearance Modification of 'ggplot2'

A flexible interface for ggplot2::theme(), potentially saving 50% of your typing.

Travis-CI Build Status Build status codecov Issue Count Project Status: WIP - Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.

ggconf provides theme2(), a flexible ggplot2::theme() interface.


g <- ggplot(iris) + geom_point(aes(Sepal.Width, Sepal.Length))
g + theme2(ax.txt(sz=20, f="bold"), ax.ln(col='gray60', sz=2),"white"))

ggconf Example

The following ggplot2 command generates the same plot.

g + ggplot2::theme(axis.text = element_text(size=20, face="bold"),
                   axis.line = element_line(colour="gray60", size=2),
                   panel.background = element_rect(fill="white"))

If you replace your ggplot2::theme() call with ggconf::theme2() call, ggconf would work. All of the followings return the same plot.

g + theme( axis.text = element_text(size=20, face="bold")) # Style 1: ggplot2 default (50 characters)
g + theme2(axis.text = element_text(size=20, face="bold")) # Style 2: ggconf
g + theme2(axis.text(size=20, face="bold"))                # Style 3: ggconf without element_text()
g + theme2(ax.txt(sz=20, face="bold"))                     # Style 4: ggconf shorter but readable
g + theme2(at(z=20, f="bold"))                             # Style 5: ggconf shortest (25 chars)


ggconf Feature Overview

Partial Match

Even if the unique identification is not possible for specified elements (e.g. theme element names or arguments), ggconf tries to execute its best estimate instead of just returning an error.

For the input theme2(ax.txt(sz=20, fc="bold"), ax.ln(col='gray60'),"white")), ggconf performs partial matches six times.

  • theme element names
    • ax.txt matches axis.text. You can even write a.t or at.
    • ax.ln matches axis.line. You can even write a.l or al.
    • matches panel.background. You can even write
      • matches plot.background according to edit distance.
  • theme configuration arguments
    • sz matches size.
    • f matches face (fontface).
      • fill needs to write not just f but fi.
    • col matches colour.


# install.packages("devtools")
  • If you get no appender.console() error, you might need install.packages('rly'). packageVersion('rly') should be at least 1.4.2.

  • This package is still in its infancy and might contain several installation bugs.


Raw ggplot2 plot

gg <- ggplot(mtcars[1:20, ] %>% tibble::rownames_to_column() %>% 
             mutate(car_name = rowname, maker = gsub(" .*", "", car_name) ) ) + 
      #geom_label(aes(mpg, qsec, label = substr(car_name, 1, 13), color=maker),
      geom_point(aes(mpg, qsec, color=maker), size=8) +
      geom_text(aes(mpg, qsec, label=substr(maker, 1, 2)), color="white", fontface="bold") +
      labs(title = "Motor Trend Car Road Tests",
           subtitle = "Top 20 rows are extracted for demonstration", 
           caption = "Source: 1974 Motor Trend US magazine") + 
           scale_x_continuous(breaks=seq(10,34, 4))

ggconf Example

After finalization

gg + 
       text(f="bold", z=24, fmly="Times New Roman"),      # make all text thicker/larger"white"),, .2, .2, .2, "cm"),"black"),
       lgd.title(fmly="Consolas", c="royalblue"),         # equally-spaced font
       axs.title(fmly="Consolas", c="royalblue"),         # colorize axis titles
       axs.title.y(angle=0, vjust=.5),                    # rotate and centerize y axis label
       axs.line(arrow=arrow(type="open", angle=20), z=2), # 
       axs.tick(z=1),                                     # tick or ticks? It doesn't matter
       axs.tick.len(.5, "cm"),
       plt.subttl(f="plain", hjust=1),
       plt.margin(.3, .3, .3, .1, "inch")                # adjust margins

ggconf Example

# If using ggplot2::theme():
gg + theme(
  text = element_text(face="bold", size=24, family="Times New Roman"),
  panel.background = element_rect(fill="white"), = margin(0.2,0.2,0.2,0.2,"cm"), = element_rect(colour="black"),
  legend.key = element_rect(fill="white"),
  legend.position = "bottom",
  legend.text = element_text(size=rel(0.8)),
  legend.title = element_text(family="Consolas", colour="royalblue"),
  axis.title = element_text(family="Consolas", colour="royalblue"),
  axis.title.y = element_text(angle=0, vjust=0.5),
  axis.text = element_text(size=rel(1.1)),
  axis.line = element_line(arrow=arrow(type="open",angle=20), size=2),
  axis.ticks = element_line(size=1),
  axis.ticks.length = grid::unit(0.5,"cm"),
  plot.subtitle = element_text(face="plain", hjust=1),
  plot.margin = margin(0.3,0.3,0.3,0.1,"inch")


The goal of ggconf is to make it less stressful to finalize your plots. + adjust colours or lineweights + rotate axis labels + decide tick label intervals and limits

Learning ggconf

ggconf follows original ggplot2 syntax as much as possible for reducing learning costs of current ggplot2 users.

Learning ggplot2 might be the best way to understand ggbash syntax. The document and book of ggplot2 would be helpful.

Other Works

ggconf draws inspiration from some other higher level programming languages including Bash, CoffeeScript, Ruby, and Lisp.

Current Implementation Status

ggbash is first released on August 24, 2017.

  • DONE:
    • version 0.1 : lightweight port from ggbash


Reference manual

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


0.1.3 by Yasutaka Tanaka, 3 months ago

Report a bug at

Browse source code at

Authors: Yasutaka Tanaka [aut, cre]

Documentation:   PDF Manual  

GPL-3 license

Imports ggplot2, rly

Suggests knitr, testthat, futile.logger, dplyr, tibble

See at CRAN