Baltazár Tivadar
Baltazár Tivadar

Reputation: 189

Manually increase values on y axis

I want to manually set the range of Y axis. I want manually increase values of Y axis by 30 units. I have a following code:

library(scales)
library(ggplot2)

ggplot(mtcars,aes(x=wt,y=mpg)) + 
  geom_point() +
  geom_smooth() +
  scale_y_continuous(trans = ~.+30)

But I got the following error message:

Error in match.fun(f) : 
  'c("~_trans", ". + 30_trans")' is not a function, character or symbol

Can somebody help me?

This is the plot what I want:enter image description here

Upvotes: 0

Views: 141

Answers (1)

Edward
Edward

Reputation: 19384

If you just want to change the labels, then this will do it.

ggplot(mtcars, aes(x=wt,y=mpg)) + 
  geom_point() +
  geom_smooth() +
  scale_y_continuous(labels=function(x) x+30)

Upvotes: 4

Related Questions