'How do I align the tick marks to the chart?

This is the chart I am referring to in my question below

In this chart I have created, there is space between the tixk marks on the x axis and the x axis/chart. How can I put the tick marks closer to the x axis so that they align?

Here is an example of tick marks that align to the x axis



Solution 1:[1]

It would be better if you could supply your code and sample data, but try adding coord_cartesian(expand = FALSE) per my made-up example 2. Per example 1, I'm wondering if the zero line is not actually your x axis.

library(tidyverse)

tibble(x = rep(1:5, 2), y = 0:9) |> 
  ggplot(aes(x, y)) +
  geom_line()

tibble(x = rep(1:5, 2), y = 0:9) |> 
ggplot(aes(x, y)) +
  geom_line() +
  coord_cartesian(expand = FALSE)

Created on 2022-05-20 by the reprex package (v2.0.1)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Carl