Search code examples
rggplot2jitter

Set size graphic in R


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


Solution

  • 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)