Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to remove text that appeared in the chart?

Am trying to plot 2 different columns of a time series data type in a single plot, however the year appears which seems to block the view of the chart. How do i remove the year in the chart so that i can see the charts nicely?
Am trying to plot 2 different columns of a time series data type in a single plot, however the year appears which seems to block the view of the chart. How do i remove the year in the chart so that i can see the charts nicely?
enter image description here
The below code is how i created the chart

data('fertil3')
fertil = ts(fertil3, frequency = 1, start = 1913)
plot(x = fertil[,"year"], y = fertil[,"gfr"], type="l", col="red", ylim = c(0, 250), xlab="Time", ylab="")
par(new=TRUE)
plot(x = fertil[,"year"], y = fertil[,"pe_1"], type="l", col="blue", ylim = c(0, 250),xlab="Time", ylab="")

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You should convert the time series object ts to as.numeric which then is a vector and can be used to plot it like lines like this:

library(wooldridge)
data('fertil3')
fertil = ts(fertil3, frequency = 1, start = 1913)
plot(x = as.numeric(fertil[,"year"]), y = as.numeric(fertil[,"gfr"]), type="l", col="red", ylim = c(0, 250), xlab="Time", ylab="")
par(new=TRUE)
plot(x = as.numeric(fertil[,"year"]), y = as.numeric(fertil[,"pe_1"]), type="l", col="blue", ylim = c(0, 250),xlab="Time", ylab="")

Created on 2022-10-15 with reprex v2.0.2

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading