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)) +
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)) +
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.