I\'m trying to plot two lines on a graph in R. The data is related to death row, with the CSV having three columns: first column is the year, second is death row population and
Here is how I would do it:
deathrow <- read.csv("death_row_by_year.csv", sep=",", header=T)
plot(range(deathrow$Year, na.rm=T), range(c(deathrow$Population, deathrow$Executions)), na.rm=T), type='n')
lines(deathrow$Year, deathrow$Population, col="red")
lines(deathrow$Year, deathrow$Executions, col="green")
The most important piece here is the call to plot
with type='n'
, so there is no point plotted but the axis are set up to the right limits. Arguably, you may also specify these limits with xlim=range(...)
and ylim=range(...)
in the calls to lines
.