List of ggplot2 theme options?

RGgplot2

R Problem Overview


After some research I found the way to prevent an uninformative legend from displaying

... + theme(legend.position = "none")

Where can I find all of the available theme options and their default values for ggplot2?

R Solutions


Solution 1 - R

The closest thing to a comprehensive list that I have been able to find is in the [ggplot2 wiki][1] 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.

[1]: https://github.com/hadley/ggplot2/wiki/-opts%28%29----theme%28%29-List "ggplot2 wiki"

Solution 2 - R

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

Solution 3 - R

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

Solution 4 - R

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.

Solution 5 - R

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.

Solution 6 - R

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

Solution 7 - R

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

Solution 8 - R

?opts although, this does not display how to finetune its arguments, therefore it's better to check the options given above. If you can get a copy of the ggplot2 reference manual, it will help you a lot.

Solution 9 - R

I made this quick reference for any theme or tasks you might look for. For a more general understanding, this ggplot2 tutorial should help.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGeorge DontasView Question on Stackoverflow
Solution 1 - Ruser399470View Answer on Stackoverflow
Solution 2 - RAndrewView Answer on Stackoverflow
Solution 3 - RSharpieView Answer on Stackoverflow
Solution 4 - RasferView Answer on Stackoverflow
Solution 5 - RRasmus LarsenView Answer on Stackoverflow
Solution 6 - RJonathan ChangView Answer on Stackoverflow
Solution 7 - RmetasequoiaView Answer on Stackoverflow
Solution 8 - RDavid DouterlungneView Answer on Stackoverflow
Solution 9 - RSelvaView Answer on Stackoverflow