title: Why is my plot on the right hand axis overwriting my existing plot?
body: <p>I am running code which I ran successfully on my work laptop. But on my home laptop when I get to the second 'plot' command it seems to start a new plot and overwrites what was there before. ????
  What has changed and how can I prevent this?</p>
  <pre><code>cases&lt;-read.csv(&quot;exporttablenewhist.csv&quot;)
  str(cases)
  date&lt;-cases[,1]
  modhistcase&lt;-cases[,2]
  realhistcase&lt;-cases[,3]
  lockdownhist&lt;-cases[,4]
  modhistdeaths&lt;-cases[,5]
  realhistdeaths&lt;-cases[,6]
  
  
  datereal&lt;-as.Date(date,&quot;%d/%m/%Y&quot;)
  
  # Create new output window
  dev.new(width=12, height=7.5) 
  # We suggest a 6&quot; by 3.75&quot; window to facilitate importing into word document (default values ~golden ratio)
  #
  # Adjust the margin of plot (bottom,left,top,right)
  par(mar=c(5, 5, 3, 7))
  #
  plot(datereal, realhistcase, type = &quot;l&quot;, lwd=2, col = &quot;green&quot;, xaxt = &quot;n&quot;, xlab=&quot;Month&quot;,ylab=&quot;Daily new cases&quot;)
  which(substr(datereal, 9, 10) == &quot;01&quot;)
  labs &lt;- datereal[substr(datereal, 9, 10) == &quot;01&quot;]
  ids &lt;- seq_along(labs)[(seq_along(labs) + 0) %% 2 == 0]
  axis.Date(1, at=labs[ids], format=&quot;%b %y&quot;, cex.axis=.9)
  
  
  lines(datereal,modhistcase, lwd=2,col = &quot;blue&quot;)
  legend(datereal[1],50000, legend=c(&quot;reported cases&quot;,
                                     &quot;modelled known cases&quot;,
                                     &quot;lockdown %&quot;),
         col=c(&quot;green&quot;,&quot;blue&quot;,&quot;red&quot;),lty=1)
  
  plot(lockdownhist,type=&quot;l&quot;,lwd=2,lty=1,col = &quot;red&quot;,xaxt = &quot;n&quot;, yaxt = &quot;n&quot;, xlab= &quot;&quot;, ylab ` 
  =&quot;&quot;,ylim=c(0,100))
  axis(side=4)
  mtext(&quot;lockdown percentage&quot;, side=4, line=3)
  axis(4,seq(0,100,by=10))
  </code></pre>
  <p>IMAGES BEFORE AND AFTER SECOND PLOT COMMAND</p>
  <p><img src="https://i.stack.imgur.com/2Sgrp.jpg" alt="before" />
  <img src="https://i.stack.imgur.com/5uTlB.jpg" alt="after" /></p>