1

I made a graphic with height and weight of person, the max of weight is 110 (beacause the the heaviest is 110) but I should set the graphic go until 150

ap90+geom_jitter(width=2, size=0.5)+labs(subtitle = "Anni 90", y="Peso", x="Altezza", title="Relazione altezza peso")

Thanks you

P.s. Sorry for my english

stefan
  • 90,330
  • 6
  • 25
  • 51
Mr Alsi
  • 37
  • 6
  • Try to include a reproducible example with some mock up data. I can see you are using ggplot2, it would be helpful to state it explicitly in your code with `library(ggplot2)`. – Duccio A Apr 10 '20 at 13:56

1 Answers1

1

Using mtcars as example data you can set the limits of the axis via the limits argument in scale_x/y_continuous. Try this:

library(ggplot2)
ggplot(mtcars, aes(hp, mpg)) + 
  geom_jitter(width=2, size=0.5) +
  # Set limits of yaxis to c(0, 60)
  scale_y_continuous(limits = c(0, 60)) +
  labs(subtitle = "Anni 90", y="Peso", x="Altezza", title="Relazione altezza peso")

Created on 2020-04-10 by the reprex package (v0.3.0)

stefan
  • 90,330
  • 6
  • 25
  • 51
  • it gevis me an error: Errore: Discrete value supplied to continuous scale – Mr Alsi Apr 10 '20 at 14:14
  • This error occurs if your variables are not numbers but are coded as characters or factors instead. Convert your vars to numeric using `as.numeric()`. – stefan Apr 10 '20 at 14:21
  • (: My pleasure. If you want do me a favor: Mark the question as answered. Besides giving me some credit it shows others with a similar problem that the solution worked and removes the question from the queue of questions still waiting for an answer. – stefan Apr 10 '20 at 14:39