title: Only one level of a four-level factor is showing in ggplot graph
body: <p>I am using the following code to produce a boxplot with a density plot:</p>
  <pre><code>ggplot(data_alk_pan, aes(x = PAN, y = MEAS_RESULT, fill = PAN)) +
    theme(legend.position = &quot;none&quot;) +
    theme(text = element_text(size = 10)) +
    scale_x_discrete(labels = paste(levels(data_alk_pan$PAN), &quot;\n(N=&quot;,table(data_alk_pan$PAN),&quot;)&quot;, sep=&quot;&quot;)) +
    labs(y = &quot;Concentration (mg/l)&quot;, x = &quot;Pan&quot;) +
    ggdist::stat_halfeye(
      aes(thickness = stat(pdf*n)),
      adjust = 0.5,
      justification = -.5,
      .width = 0,
      point_colour = NA
    ) +
    geom_boxplot(alpha = 0.5, varwidth = TRUE)
  </code></pre>
  <p>It works perfectly for every other factor I have in my data (i.e. if I point to a different column in my dataframe other than PAN) but for some reason it will only show the first level of the factor PAN.</p>
  <p>I have checked that R recognises all of the levels in the factor by running the following:</p>
  <pre><code>levels(data_alk_pan$PAN)
  </code></pre>
  <p>which returns</p>
  <pre><code>[1] &quot;Pan_01&quot;  &quot;Pan_02&quot;  &quot;Pan_03&quot;  &quot;Pan_all&quot;
  </code></pre>
  <p>which is what I would expect.  However, only the first level (Pan_01) is showing in the plot.  All of the levels have data (i.e. n&gt;0 for all levels).</p>
  <p>Any thoughts on what I am missing or what I can do to get all four levels to show in the plot?</p>
  <p>Updated query to include some of the data:</p>
  <pre><code>&gt; dput(data_alk_pan[1:200, c(8,13)])
  structure(list(MEAS_RESULT = c(170, 180, 150, 140, 160, 140, 
  330, 130, 130, 210, 130, 130, 310, 400, 200, 160, 160, 160, 170, 
  170, 220, 170, 200, 240, 200, 190, 200, 180, 190, 240, 250, 260, 
  280, 270, 250, 290, 260, 260, 250, 230, 270, 260, 220, 260, 250, 
  310, 270, 86, 270, 150, 290, 290, 300, 290, 270, 210, 280, 300, 
  390, 270, 190, 240, 240, 260, 210, 250, 210, 220, 190, 260, 210, 
  190, 240, 280, 240, 210, 220, 220, 200, 250, 310, 260, 290, 280, 
  180, 280, 310, 310, 300, 300, 280, 190, 180, 180, 200, 210, 180, 
  280, 390, 290, 320, 310, 320, 260, 330, 330, 390, 300, 350, 270, 
  190, 180, 310, 270, 300, 270, 330, 310, 320, 310, 340, 330, 340, 
  270, 340, 57, 360, 28, 320, 170, 21, 370, 320, 330, 430, 340, 
  300, 350, 300, 300, 340, 260, 270, 230, 180, 210, 210, 240, 230, 
  260, 250, 230, 250, 270, 280, 170, 190, 190, 190, 180, 190, 250, 
  250, 260, 270, 180, 260, 260, 260, 260, 250, 260, 280, 290, 130, 
  150, 190, 180, 190, 240, 270, 260, 230, 220, 170, 190, 270, 270, 
  260, 280, 260, 260, 270, 280, 290, 270, 190, 230, 240, 170), 
      PAN = structure(c(4L, 4L, 4L, 4L, 4L, 4L, 1L, 4L, 4L, 1L, 
      4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 
      2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
      2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
      2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
      2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
      2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
      3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
      3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c(&quot;Pan_01&quot;, 
      &quot;Pan_02&quot;, &quot;Pan_03&quot;, &quot;Pan_all&quot;), class = &quot;factor&quot;)), row.names = c(NA, 
  200L), class = &quot;data.frame&quot;)
  </code></pre>