title: How to rename the labels of the fill variable in a grouped plot in R
body: <p>I need change the labels with custom labels that are not in the data because I want to introduce some latex formulas in the labels.</p>
  <p>To illustrate the issue I will use an example I copied from <a href="https://www.r-graph-gallery.com/48-grouped-barplot-with-ggplot2" rel="nofollow noreferrer">https://www.r-graph-gallery.com/48-grouped-barplot-with-ggplot2</a>.</p>
  <pre class="lang-r prettyprint-override"><code># library
  library(ggplot2)
  library(latex2exp)
  
  # create a dataset
  specie &lt;- c(rep(&quot;sorgho&quot; , 3) , rep(&quot;poacee&quot; , 3) , rep(&quot;banana&quot; , 3) , rep(&quot;triticum&quot; , 3) )
  condition &lt;- rep(c(&quot;normal&quot; , &quot;stress&quot; , &quot;Nitrogen&quot;) , 4)
  value &lt;- abs(rnorm(12 , 0 , 15))
  data &lt;- data.frame(specie,condition,value)
   
  # Grouped
  ggplot(data, aes(fill=condition, y=value, x=specie)) + 
      geom_bar(position=&quot;dodge&quot;, stat=&quot;identity&quot;)
  </code></pre>
  <p>This example produces the following plot:</p>
  <p><a href="https://i.stack.imgur.com/ixy3i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ixy3i.png" alt="enter image description here" /></a></p>
  <p>Instead of the labels <code>Nitrogen</code>, <code>normal</code>, and <code>stress</code>, I want to use latex formulas as <code>TeX('$\\alpha^2$')</code>, <code>TeX('$\\beta^3$')</code> and <code>TeX('$\\alpha+\\beta$')</code>.  Of course, I prefer to modify the plot, but not the data.  How can I do it?</p>