Increasing number of tick marks on a horizontal axis and expanding the vertical axis

Hi! Thanks for reading this. In short I'm trying to do two things with ggplot.

  1. Increasing the number of tick marks on my horizontal axis. For example, (See image) only 5, 10, and 15 are present. This makes it interpret the graph. How would I add more numbers on that axis (maybe multiples of 2 or something)?
    2.) Similar to the first question, how would I expand the vertical axis to beyond the current numbers present? Just it smooths out the graph. For example, expand the axis to 110.

Thank you

Rplot

AggHR<-tibble::tribble(
                ~V1,  ~V2,  ~V3,  ~V4,  ~V5,  ~V6,  ~V7,  ~V8,  ~V9, ~V10, ~V11, ~V12, ~V13, ~V14, ~V15, ~V16, ~V17, ~V18, ~V19,
        "ID Number",   0L,   1L,   2L,   3L,   4L,   5L,   6L,   7L,   8L,   9L,  10L,  11L,  12L,  13L,  14L,  15L,  16L,  17L,
       "Count Down",  66L,  66L,  64L,  64L,  58L,  58L,  58L,  57L,  56L,  56L,  57L,  57L,  57L,  57L,  57L,  57L,  57L,  57L,
  "Social Stressor",  85L,  84L,  83L,  81L,  80L,  79L,  78L,  78L,  79L,  80L,  80L,  81L,  81L,  81L,  80L,  80L,  80L,  81L,
       "Count Down", 103L, 103L, 103L, 103L, 103L, 103L, 103L, 103L, 103L, 103L, 103L, 103L, 103L, 103L, 103L, 104L, 104L, 104L,
       "Count Down", 115L, 115L, 114L, 114L, 114L, 114L, 112L, 111L, 110L, 109L, 109L, 108L, 109L, 110L, 111L, 112L, 112L, 111L,
  "Social Stressor",  49L,  48L,  46L,  46L,  45L,  46L,  45L,  45L,  45L,  45L,  46L,  46L,  47L,  48L,  48L,  50L,  51L,  50L,
       "Count Down",  70L,  69L,  68L,  68L,  69L,  69L,  69L,  69L,  68L,  69L,  70L,  71L,  72L,  72L,  73L,  74L,  74L,  73L,
  "Social Stressor",  79L,  78L,  67L,  67L,  68L,  62L,  62L,  62L,  63L,  72L,  72L,  82L,  81L,  82L,  83L,  82L,  81L,  81L,
       "Count Down", 240L, 202L, 141L, 106L,  89L,  74L,  71L,  71L,  71L,  72L,  74L,  77L,  77L,  70L,  68L,  68L,  58L,  55L,
  "Social Stressor",  78L,  78L,  77L,  76L,  75L,  75L,  75L,  75L,  76L,  76L,  76L,  76L,  77L,  76L,  76L,  77L,  77L,  77L,
       "Count Down",  66L,  66L,  66L,  66L,  66L,  66L,  67L,  67L,  67L,  67L,  68L,  68L,  68L,  67L,  67L,  67L,  67L,  66L,
       "Count Down",  66L,  66L,  76L,  76L,  76L,  77L,  75L,  75L,  75L,  75L,  76L,  76L,  77L,  79L,  79L,  77L,  77L,  67L,
       "Count Down",  76L,  76L,  77L,  76L,  76L,  76L,  75L,  75L,  76L,  79L,  79L,  79L,  78L,  76L,  76L,  75L,  75L,  76L,
       "Count Down",  66L,  68L,  68L,  67L,  66L,  67L,  68L,  69L,  69L,  68L,  68L,  68L,  70L,  72L,  71L,  69L,  68L,  69L,
       "Count Down",  65L,  65L,  65L,  65L,  65L,  65L,  66L,  66L,  65L,  65L,  66L,  66L,  67L,  67L,  68L,  69L,  69L,  69L,
  "Social Stressor",  67L,  65L,  65L,  64L,  58L,  61L,  55L,  60L,  60L,  60L,  60L,  66L,  66L,  72L,  72L,  82L,  83L,  82L,
       "Count Down",  59L,  60L,  60L,  60L,  60L,  60L,  59L,  60L,  59L,  61L,  64L,  64L,  64L,  64L,  72L,  65L,  68L,  69L,
       "Count Down",  78L,  78L,  81L,  81L,  82L,  85L,  87L,  85L,  73L,  73L,  72L,  71L,  71L,  74L,  89L,  92L,  95L,  94L,
       "Count Down",  58L,  60L,  60L,  59L,  60L,  59L,  58L,  59L,  61L,  62L,  63L,  64L,  64L,  65L,  65L,  65L,  65L

Here is my code:

library(tidyverse)

View(AggHR)

AggHR %>%
group_by(V1) %>%
summarize_if(is.numeric, mean) %>%
pivot_longer(-V1) %>%
filter(V1 != "ID Number") %>%
mutate(time = str_sub(name, 2) %>% as.numeric()) %>%
ggplot() +
aes(time, value, color = V1) +
geom_line()

addon these additional ggplot commands:

 +
  scale_x_continuous(breaks = 2*(1:10)) +
  scale_y_continuous(limits=c(50,110))
2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.