editing x axis in line chart

I made a simple line chart which I have attached. However, the x-axis is showing an interval of 5 years so can you please help me to make a graph with an interval of 2-3 years.
Thanks in advance.

Please always share your code. Also, note that this is not a ggplot.

A quick Google search delivers for example this link or this one that explain everything you need to know for handling axes in base R. You will find that you have to add axis(1, seq(2004, 2020, 2)) to your code.

1 Like

data_forward_spot <- read.csv("forward_rates_USD_vs_INR_spot_1m_3m_6m_12m.csv")

data_forward_spot$date <- dmy(data_forward_spot$date)
This is the code.
plot(data_forward_spot$date, data_forward_spot$forward_1m, type = "l",col = "red",ylim = c(-0.5,3.0),
xlab = "Year", ylab = "Forward rate (INR)", lwd= 2,main = "Forward rates for 1M, 3M, and 6M")
lines(data_forward_spot$date, data_forward_spot$forward_3m, type = "l",col = "blue", lwd= 2)
lines(data_forward_spot$date, data_forward_spot$forward_6m, type = "l",col = "green", lwd= 2)
legend("bottomright", legend=c("1-Month", "3-Months","6-Months"),
col=c("red", "blue","green"), lty = 1:2, cex=0.7)

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