title: Only displaying top 3 bars in a ggplot2 chart
body: <p>I am trying to figure out a way to display only the top three bars of a data set. In order to make things simple, I'm using the diamond data set to illustrate what I'd like to do. First, I ordered it by largest to smallest.</p>
  
  <pre><code>library(data.table)
  diamonds &lt;- data.table(diamonds)
  diamonds1 &lt;- within(diamonds, cut &lt;- factor(cut, levels=names(sort(table(cut), decreasing=TRUE))))
  </code></pre>
  
  <p>Then, I plotted. </p>
  
  <pre><code>ggplot(diamonds1, aes(cut, fill=cut)) + geom_bar(position="dodge") + guides(fill=FALSE) + ylab("Count") + xlab("Cut")
  </code></pre>
  
  <p>And I got this:</p>
  
  <p><img src="https://i.imgur.com/yK8LTRG.png" alt="My plot"></p>
  
  <p>But instead of seeing all of the bars, I just want to see the top three. Additionally, I want this to be repeatable, so if the data set changes and there is a different top three, I can use the same code to create the correct top three. Is there any way to do this?</p>