I know that after I create a ggplot graph I can use theme_get()
to return detail of all the theme elements. This has been very helpful in figuring out things like strip.text.x
and the like. But I have two things I can't figure out:
1) In the following ggplot graphic, what is the name of the theme item representing the phrase "Percent of wood chucked by the woodchuck" as I want to resize it to a larger font:
2) How do I reformat the y axis labels to read 10%, 20, ... instead of .1, .2, ...
For 1), it is $axis.title.y
p + theme(axis.title.x = element_text(size = 25))
where p
is an existing ggplot object.
I don't know about 2) off hand.
For (2) what you want is to use a formatter
:
dat <- data.frame(x=1:10,y=1:10)
#For ggplot2 0.8.9
ggplot(dat,aes(x = x/10,y=y/10)) +
geom_point() +
scale_x_continuous(formatter = "percent")
#For ggplot2 0.9.0
ggplot(dat,aes(x = x/10,y=y/10)) +
geom_point() +
scale_x_continuous(labels = percent_format())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With