title: How to italicize part (one or two words) of x-axis labels using multiple lines
body: <p>(This is my first question on this forum, sorry in advance if it's not that clear!)</p>
  
  <p>I am trying to rename the labels of the x axis of a graph made with ggplot2 in a way that:</p>
  
  <ol>
  <li>it appears on two lines, and</li>
  <li>some of the characters are in italic.</li>
  </ol>
  
  <p>I have found two answers to help me with this problem, the first regarding italic in titles (<a href="https://stackoverflow.com/questions/32555531/how-to-italicize-part-one-or-two-words-of-an-axis-title?answertab=votes#tab-top">How to italicize part (one or two words) of an axis title</a>), the second regarding writing titles on two lines (<a href="https://stackoverflow.com/questions/20123147/add-line-break-to-axis-labels-and-ticks-in-ggplot">Add line break to axis labels and ticks in ggplot</a>).</p>
  
  <p>Unfortunetaly, when I try those two solutions together, it doesn't work. </p>
  
  <p>My case is a bit complex, so let me show you a simple analogous example, using the mtcars dataset. </p>
  
  <p><strong>Here's the base code:</strong></p>
  
  <pre><code>base &lt;- mtcars %&gt;% ggplot(aes(x = factor(cyl))) +
    geom_bar() +
    scale_y_continuous(breaks = 0:20) +
    xlab(NULL)
  
  base
  </code></pre>
  
  <p><strong>Which gives this:</strong>
  <a href="https://i.stack.imgur.com/rKsZd.png" rel="nofollow noreferrer">Base graph</a></p>
  
  <p><strong>What I want is this (I completed it in Paint):</strong> <a href="https://i.stack.imgur.com/yN9dG.png" rel="nofollow noreferrer">Desired graph</a></p>
  
  <p><strong>The best I can do, based on my findings, is this:</strong></p>
  
  <pre><code>addline_format &lt;- function(x,...){
    gsub('\\s','\n',x) 
    }
  
  my_x_titles &lt;- c(expression(paste("4 cylinders (", italic("N"), " = 11)")),
                   expression(paste("6 cylinders (", italic("N"), " = 7)")),
                   expression(paste("8 cylinders (", italic("N"), " = 14)")))
  
  base + scale_x_discrete(breaks = c(4, 6, 8),
                          labels = addline_format(my_x_titles))
  </code></pre>
  
  <p><strong>Which gives something not great:</strong> <a href="https://i.stack.imgur.com/Czosc.png" rel="nofollow noreferrer">My not-great solution</a> </p>
  
  <p>Using the homemade <em>addline_format</em> function seems to block the effect the <em>italic</em> function. Moreover, I'd like the labels to be on only two lines (please refer to my Desired solution picture), not multiple, even though I use multiple spaces.</p>
  
  <p>Anyone would know how to solve this? </p>