Plot multiple lines with a character as x-axis
<p>I have a daily time series that runs across several years. I would like a plot for each year, on the same graf. </p>

<p>So, I have all my dates of the year, in the format %m-%d and a single point for each year. </p>

<p>Data example: </p>

<pre><code>require(dplyr)
require(ggplot2)

df &lt;- data.frame(Date = seq.Date(from = as.Date("2013-01-01"), 
                                 to = as.Date("2016-10-01"), by = "day"), 
                 xv = rnorm(1370))

# First I add my x-axis (Days) and my factor variable (Year)
df &lt;- df %&gt;% mutate(Year = format(Date, "%Y"), 
                    Days = format(Date, "%m-%d")) %&gt;% select(Date, Year, Days, xv)
</code></pre>

<p>Essentially it should sort like this: (Except Year shouldn't be on the x-axis)
<a href="https://i.stack.imgur.com/WWgiK.png" rel="nofollow"><img src="https://i.stack.imgur.com/WWgiK.png" alt="enter image description here"></a></p>

<p>Now, I can easily do a faceted plot, but this contains empty space for the following year, which I don't want, and I also really would like all lines on the same graph. </p>

<pre><code># Wrong faceted graph
ggplot(df, aes(x = Date, y = xv, group = Year, colour = Year)) + 
  geom_line() +
  facet_grid(.~Year)
</code></pre>

<p>I've tried variations of setting group = 1, so you can plot using a character/factor as x-variable, but then you can't plot more than one line. Data can contain missing variables or incomplete days (leap-years and such). I would really prefer a ggplot solution. </p>