Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 211995

Adding expressions to ggplot axis tick marks

$
0
0

I would like to add something like 10^ to each tick mark label on my X and/or Y axis tick labels.

I know this can be done in facet_grid by using a labeller like label_bquote but I am curious if there is a way to do this for tick labels.

p <- ggplot(mpg, aes(displ, cty)) + geom_point()
p + facet_grid(rows = vars(drv),labeller = label_bquote(rows=sigma==10^.(drv)))

This example code adds 10^ to the labels of each facet row and, as of now, if I want to add 10^ to each X axis tick then I would do something along the lines of: p+scale_x_continuous(labels=expression("10"^"2","10"^"3","10"^"4","10"^"5","10"^"6","10"^"7"),breaks = c(2,3,4,5,6,7))

My Question Is: Is there a built-in function that will allow me to add an expression to each break? My current method leaves room for human error.


Viewing all articles
Browse latest Browse all 211995

Trending Articles