title: adding color bar in a simple line plot with defined rainbow colors in R
body: <p>I want to make a line plot with several lines, whereby each line corresponds to a defined color. Then I want to show the color bar aside the plot. It is straightforward to define and plot the lines (as a simple example below), but I could not put the bar plot  ( I have tried different approaches). Notice: I dont want to use ggplot2.</p>
  
  <pre><code>n =30
  color=rainbow(n, s = 1, v = 1, start = 0, end = max(1, n - 1)/n, alpha = 1)
  x=seq(1:10) 
  plot(x,1*x,col=color[1],type="l")
  for (i in seq(2,30)){
    lines(x,i*x,col=color[i])}
  </code></pre>