0

enter image description here

How do you adjust the line graph to avoid so much spare space?. Is scale alpha the way to trim the line graph?.

ggplot(cdata) + 
  geom_line(aes(x = Date, y = Value)) +
markus
  • 25,843
  • 5
  • 39
  • 58
  • Does this answer your question? [set date range in ggplot](https://stackoverflow.com/questions/14162829/set-date-range-in-ggplot) – Paul May 09 '22 at 06:52

1 Answers1

0

You can use the scale_x_* and scale_y_* family of functions in ggplot2 to control the scaling and limits of the axes.

Assuming your cdata$Date is a Date, you can do the following:

ggplot(cdata) +
  geom_line(aes(x = Date, y = Value)) +
  scale_x_date(limits = as.Date(c("2020-01-01", "2020-12-31")))

EDIT: If you are looking to scale the y axis, it is continuous, so you could use scale_y_continuous(). There are also other scaling functions available, like scale_*_discrete(), scale_*_log10(), and scale_*_reverse(), depending on the type of values on your axes.