R - ggplot2 - X Axis labels won't be displayed
<p>I have a function <code>plotmonthly2</code> that uses the package <code>ggplot2</code> to graphicaly display monthly developments of my data.</p>

<h3>plotmonthly2:</h3>

<pre><code>plotmonthly2 &lt;- function (my_data) {

  ymin &lt;- 0
  ymax &lt;- max(my_data[my_data[6] == unique(my_data[,6])[1], 4])+max(my_data[my_data[6] == unique(my_data[,6])[2], 4])

  ggplot(my_data, aes( Cat, value)) +
    geom_area(aes(fill= type), position = 'stack') +
    scale_y_continuous(expand = c(0,0), limits = c(ymin,ymax)) +
    scale_fill_manual(values = c("#797978", "#a6a4a1")) +
    scale_x_discrete(expand = c(0,0), labels = gsub(" 20"," ",my_data$monthYear)) +
    theme(axis.text.x = element_text(angle=90, vjust=1, face="bold", size=7, colour = "#016576"),
          axis.title = element_blank(),
          axis.text.y = element_blank(),
          axis.ticks=element_blank(),
          axis.line.x = element_line(color="black", size = 2),
          panel.background = element_rect(fill = "transparent",colour = NA),
          panel.grid.minor = element_blank(), 
          panel.grid.major = element_blank(),
          legend.position = "none",
          plot.background = element_rect(fill = "transparent",colour = NA)) 
}
</code></pre>

<p>However, when I plot the dataframe, the x axis labels are not displayed:</p>

<pre><code>pmKM &lt;- plotmonthly2(monthlyKMDef)
</code></pre>

<p><a href="https://i.stack.imgur.com/bgGAJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bgGAJ.png" alt="Plot without x axis labels"></a></p>

<p>This is the structure of my dataframe:</p>

<pre><code>&gt; dput(monthlyKMDef)
monthlyKMDef &lt;- structure(list(month = c("Mai", "Jun", "Jul", "Aug", "Sep", "Okt", 
"Nov", "Dez", "Jan", "Feb", "Mrz", "Apr", "Mai", "Mai", "Jun", 
"Jul", "Aug", "Sep", "Okt", "Nov", "Dez", "Jan", "Feb", "Mrz", 
"Apr", "Mai"), year = c("2015", "2015", "2015", "2015", "2015", 
"2015", "2015", "2015", "2016", "2016", "2016", "2016", "2016", 
"2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", 
"2016", "2016", "2016", "2016", "2016"), variable = structure(c(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), .Label = "Count", class = "factor"), 
    value = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 134, 166, 191, 237, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 49, 90, 173), monthYear = structure(c(2015.33333333333, 
    2015.41666666667, 2015.5, 2015.58333333333, 2015.66666666667, 
    2015.75, 2015.83333333333, 2015.91666666667, 2016, 2016.08333333333, 
    2016.16666666667, 2016.25, 2016.33333333333, 2015.33333333333, 
    2015.41666666667, 2015.5, 2015.58333333333, 2015.66666666667, 
    2015.75, 2015.83333333333, 2015.91666666667, 2016, 2016.08333333333, 
    2016.16666666667, 2016.25, 2016.33333333333), class = "yearmon"), 
    type = c("Eigene", "Eigene", "Eigene", "Eigene", "Eigene", 
    "Eigene", "Eigene", "Eigene", "Eigene", "Eigene", "Eigene", 
    "Eigene", "Eigene", "Mentions", "Mentions", "Mentions", "Mentions", 
    "Mentions", "Mentions", "Mentions", "Mentions", "Mentions", 
    "Mentions", "Mentions", "Mentions", "Mentions"), Cat = c(1L, 
    2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 1L, 2L, 
    3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L)), .Names = c("month", 
"year", "variable", "value", "monthYear", "type", "Cat"), row.names = c(NA, 
-26L), class = "data.frame")
</code></pre>

<p>It doesn't matter how many times I doublecheck my function, I am not able to find why the axis is not been displayed. Can someone see where the problem is?</p>