ggplot title centring problem

58 views
Skip to first unread message

Liam Bailey

unread,
Dec 19, 2016, 6:18:25 AM12/19/16
to ggplot2
Hi all,

I've noticed that plot titles in ggplot are not being centred at the top of the plot. I'm using ggplot 2.2.0; R 3.3.2; Windows 7 SP1.

For example:

ggplot(cars, aes(x = speed, y = dist))+
geom_point()+
ggtitle("cars title")

OR

ggplot(cars, aes(x = speed, y = dist))+
geom_point()+
labs(title = "cars title")

(result is the same)



Is this a known bug in the current version? What would people recommend as the best work around to centre plot titles.

Cheers,
Liam

Crump, Ron

unread,
Dec 19, 2016, 6:30:11 AM12/19/16
to Liam Bailey, ggplot2
Hi Liam,

>ggplot(cars, aes(x = speed, y = dist))+
>geom_point()+
>labs(title = "cars title")

How about:
ggplot(cars, aes(x = speed, y = dist))+
geom_point()+labs(title = "cars
title")+theme(plot.title=element_text(hjust=0.5))

See ?theme and ?element_text

Ron.

Thiago V. dos Santos

unread,
Dec 19, 2016, 8:41:16 AM12/19/16
to Liam Bailey, ggplot2
Rather than a bug, this appears to be a new feature. Check first paragraph of
https://github.com/tidyverse/ggplot2/releases/tag/v2.2.0
Greetings,
-- Thiago V. dos Santos

PhD student
Land and Atmospheric Science
University of Minnesota


On Monday, December 19, 2016 5:18 AM, Liam Bailey <ldbai...@gmail.com> wrote:



Hi all,

I've noticed that plot titles in ggplot are not being centred at the top of the plot. I'm using ggplot 2.2.0; R 3.3.2; Windows 7 SP1.

For example:

ggplot(cars, aes(x = speed, y = dist))+
geom_point()+
ggtitle("cars title")

OR

ggplot(cars, aes(x = speed, y = dist))+
geom_point()+
labs(title = "cars title")

(result is the same)



Is this a known bug in the current version? What would people recommend as the best work around to centre plot titles.

Cheers,
Liam
--
--
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

To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Liam Bailey

unread,
Dec 19, 2016, 7:28:35 PM12/19/16
to ggplot2, ldbai...@gmail.com, thi_v...@yahoo.com.br
Thanks all, makes much more sense now. Should've checked recent documentation!
Reply all
Reply to author
Forward
0 new messages