Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of ggplot2 theme options?

Tags:

r

ggplot2

The closest thing to a comprehensive list that I have been able to find is in the ggplot2 wiki on github. I think that most of the options are covered there with examples.

Update If you would like to see the options that are in use on a current plot, you can use plot_theme(x) to see all of the options that are currently set for the plot named x. It will not be a comprehensive list, but should help if you want to change something like the font size for an axis label.

Update 2 With the transition to version 0.9.0 it's worth noting that the built in documentation has been dramatically improved, and the transition guide from 0.8.9 to 0.9.0 is also worth checking out.

Update 3 There is now a ggplot2 documentation website. Look at the documentation for theme for a complete list. Also, ?theme has a pretty complete list as of 0.9.3.

Update 4 There is now a ggthemes package that has some nice themes and scales to choose from. It might save you from having to create your own. See their github page for more information.


Entering in

theme_get()

will show a comprehensive listing of theme values and options. You can then follow the syntax to modify these attributes in opts().


The ggplot2 package does not contain much reference information-- this is probably because Hadley has put a lot of work into developing and polishing the package, creating a website full of examples and writing an excellent book that describes the system in detail.

The first place I would look for answers would be the ggplot2 website:

http://docs.ggplot2.org/

However, since opts() is not really a geom, stat or scale there are no examples that focus specifically on it. The next place to look would be the section of the website that contains material from the book-- including source code for examples:

http://ggplot2.org/book/

The example code for the chapter "Polishing your plots for publication" contains some well commented examples of using set_theme() and opts() to alter plot appearance.

The ultimate source for information is of course the book it's self. If you find ggplot2 has simplified and streamlined your workflow for producing statistical graphics, buying a copy of the book is a great way to say "thank you" and support the further development of the package.

Update

After some further investigation, you may be able to find a relatively complete list of options by listing out the source of one of the "theme" functions such as theme_bw. The source doesn't provide a description of the possible key=value pairs, but it does at least show most of the key names that have an effect when set via opts().


Besides the obvious references to ggplot2 reference manual and to the graphs section of Cookbook for R, Hadley Wickham provides a nice opts() List on github.


Theme templates:

https://github.com/jrnold/ggthemes

like "The economist", "Stata", "tufte" and more..

I know the answer is not exactly what was asked, but it was what I was looking for when I found this question, so others might too.


All the options I've ever used have been explained in hadley's great ggplot2 book.


Best list I've found for version 0.9.2.1 is here.