title: How to show just the legend in R?
body: <p>I want to create a legend to depict what different colors mean. Like the image below:
  <a href="https://i.stack.imgur.com/PRlwj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PRlwj.png" alt="enter image description here" /></a></p>
  <p>I'm able to achieve this by passing Null values to plot but the plot takes up a lot more white space around it. (Screenshot attached below).
  Is there any other way using which I can just show legend.
  <a href="https://i.stack.imgur.com/STAyj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/STAyj.png" alt="enter image description here" /></a>
  Here's the piece of code I used.</p>
  <pre><code>plot(NULL ,xaxt='n',yaxt='n',bty='n',ylab='',xlab='', xlim=0:1, ylim=0:1)
  legend(&quot;topright&quot;, horiz = T, legend =c('Good', 'Bad', 'Poor'), pch=15, pt.cex=5, cex=1.5, bty='n', col = c('#3d9970','#ff851b', '#dd4b39'))
  </code></pre>