Quick reference sheet for legends, axes and themes

Skip to first unread message

Hadley Wickham

Jun 29, 2010, 8:59:17 AM6/29/10
to ggplot2
Hi everyone,

One of the biggest adjustments to ggplot2 is learning how you make
changes to the legends and axes (through the scales). The info needed
to make these changes is scattered around the book and the
documentation, and so I've been working with a graphic design student
to make a quick reference sheet that puts all this info in one place.
I've attached a draft version and would really like to hear your
comments. What works well? What's missing?



Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University

ggplot2 4-1.pdf

baptiste auguie

Jun 29, 2010, 9:41:19 AM6/29/10
to Hadley Wickham, ggplot2

Looking good. A couple of quick comments:

- how to add plotmath expressions

- quotation marks from the example code won't run when copy-pasted
from the reference card, maybe the typographic style could be adapted
a little for usability,

theme_rect(fill = “grey80”)


theme_rect(fill = "grey80")



> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

Brian Diggs

Jun 29, 2010, 3:55:10 PM6/29/10
to ggplot2
My thoughts/ideas/comments after looking at this:

In the introduction, maybe reiterate the idea that each "column" of
data is mapped via a scale, whether that is in terms of position,
color, size, etc., and that scales are treated consistently. That was
the fundamental concept that took awhile to sink in, but when it did,
everything came together much better. But I am also a theoretician
and (more?) happy at the concept level.

I would think that for a quick reference guide (designed, it seems, to
be one sheet, double sided, not folded), an "In this guide:" section
would be unnecessary

Axis Properties:

For titling and limits, you mention the "shortcut" functions xlab,
ylab, labs, xlim, ylim; but for tick marks you talk about the breaks
and labels options. Unfortunately, you call them "commands" which
make me think they would be stand-along functions. However, I know
that they are options to the scale_*_* functions; I would not get that
from this, though.

The examples in titling are quasi-runnable (if p were defined);
changing axis limits are not (what is one to do with this fragment?);
changing axis tick marks is even worse (generalizing from above, I
would guess p = p + breaks=c(4,5,6) )

The font used for the function names and arguments appears fuzzy or
smudged out to me (Windows XP, Adobe Reader 7.0, viewing at 100%). If
I am reading the fonts info correctly in the document properties
correctly, all the fonts are embedded, so I don't think that is the

Legend properties:

Same problem as in axis properties; if you didn't already know where
breaks and labels went, you would not have any idea what to do with

Colour scales:

I think "data outline" and "data fill" could just as easily be
"outline" and "fill" in the titles

In "Common scale commands and arguments", _brewer(pal="arg") can be
either a discrete, gradient, or divergent scale; not just a discrete

Theme elements:

Since the point is made that the right theme_* must be used, it would
be worth mentioning in theme_blank() that theme_blank() can be used in
place of any theme (theme_text(), theme_rect(), theme_line(), or

Making these more runnable examples would help; while each example is
correct, it does not really do anything. p + opts(panel.title =
theme_text(size=20, face="bold")) [with p define previously] would be

"line" and "rect" are switched, either in the text or in the labels
beside the section title.

I really like the mini-table-of-contents with each heading pointing to
the relevant section. Since sections are short (don't go onto the
next page), this works well.

Please take these suggestions as they are intended: ideas to make a
good idea and execution even better. I apologize in advance if any of
them came across as too terse or harsh.

--Brian Diggs
>  ggplot2 4-1.pdf
> 285KViewDownload


Jun 30, 2010, 10:38:22 AM6/30/10
to ggplot2
I have only two days of expezrience in ggplot2, and not much more in R
(although I have decent skills in many other languages and software).
My comments may or may not be of any help for improving your material.
Anyway, I feel this sheet should be usefull as a reminder fo those
having already an expertise in ggplot.
At the point where I am, I am struggling with the documentation
because there is nowhere a comprehensive reference book or website
where all the information is settled.

I am coming from Matlab, which documentation is really awsome. I
understand that pay-software maintained by tens of people cannot
compare with a one-man work realeased for free to the community. This
is just an example.
May I suggest you to turn you documentation website into a wiki, so
that anyone who have seached for an information, and finally found it,
can post it at the right place on the wiki.
You will need a couple minutes a day to validate, move, edit or
discard the changes and the documentation will grow by itself :-)

Joshua Wiley

Jun 30, 2010, 11:21:14 AM6/30/10
to Hadley Wickham, ggplot2

I like the headings on the sides of the pages that lead to content;
they make it easy to find something quickly (good in a reference
sheet). I would agree with Brian that the 'In this guide' section is
not needed.

I think it would be nice if there was some sort of graphical schematic
for how everything fits together. Something like a graph with little
arrows saying 'scale_x_continuous controls this', 'title set by...',
etc. My idea is that someone could look at this graph, point to the
thing they wanted to change on theirs (e.g., the x axis tick marks and
labels) and see the relevant function/argument name. This would offer
a graph --> code flow rather than code --> graph. I do not know if
this is reasonable/possible to make at all, and particularly in
limited space.

The font does seem a bit fuzzy, but I have not tried printing it and
it improves when I zoom in (actually that just sounds like I need new

Thanks for the great work!

Best regards,


> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles


Jul 1, 2010, 5:41:52 PM7/1/10
to ggplot2
I agree with both Josh and Brian. Also some usage examples of the
'opts()' argument (as it applies to legends and plot annotation) would
be very helpful

Hadley Wickham

Jul 3, 2010, 10:21:29 AM7/3/10
to ggplot2
Thanks for all the feedback!


Aug 4, 2012, 5:55:39 PM8/4/12
to ggp...@googlegroups.com, had...@rice.edu
Hi Hadley, coming across this quick reference sheet was great. I was wondering if there have been additions since this 2010 version and if you could please email me the latest version. Kind regards,

Roman Luštrik

Jan 8, 2013, 4:46:08 PM1/8/13
to willi...@gmail.com, ggp...@googlegroups.com, had...@rice.edu
For starters, you could try https://github.com/hadley/ggplot2/wiki/%2Bopts%28%29-List
A lot has changed since 2010. Help files may also be of some help (e.g., see ?theme).


On Mon, Jan 7, 2013 at 10:20 PM, <willi...@gmail.com> wrote:
I'd also be interested in Ahsan's inquiry, just curious if comments were ever incorporated into a new version. Super useful!


You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

In God we trust, all others bring data.
Reply all
Reply to author
0 new messages