What is the width argument in position_dodge?
<p><a href="https://ggplot2.tidyverse.org/reference/position_dodge.html" rel="nofollow noreferrer">The documentation of <code>position_dodge</code></a> does not explain what exactly is this <code>width</code> argument</p>
<ol>
<li>Whose width does it specify?</li>
<li>What's the &quot;unit&quot;?</li>
<li>What's the default value?</li>
</ol>
<p>The default value is <code>width = NULL</code>, but trial and error shows that <code>width = 0.9</code> seems to produce the default effect (see postscript). However, <a href="https://github.com/hadley/ggplot2/blob/5f4af9eafed9cbd7e3c84285fe3c9047f1ccb17d/R/position-dodge.r" rel="nofollow noreferrer">I couldn't find where such default value is set in <code>ggplot2</code> source code</a>. Thus,</p>
<ol start="4">
<li>Could you explain how the default dodge is implemented in <code>ggplot2</code> code?</li>
</ol>
<p>The spirit of the question is to allow <code>ggplot2</code> users to find appropriate <code>width</code> values without trial and error.
PS:</p>
<pre><code>ggplot(data = df) +
  geom_bar(aes(x, y, fill = factor(group)), 
           position = position_dodge(), stat = &quot;identity&quot;)

ggplot(data = df) +
  geom_bar(aes(x, y, fill = factor(group)), 
           position = position_dodge(0.9), stat = &quot;identity&quot;)
</code></pre>