title: Custom spacing between x axis labels in ggplot
body: <p>I have a df:</p>
  
  <pre><code>   Year          Ratio       N    Mean        sd        se        ci
  97  1867 TILLBANK...PLACTILL 2  3.861999  4.082170  2.886530  36.67685
  98  1867   TILLOBL..PLACTILL 2 21.848833 17.859532 12.628596 160.46153
  99  1867   TILLLOAN.PLACTILL 2 54.197044 23.309360 16.482207 209.42629
  100 1867   TILLEQUI.PLACTILL 2  0.000000  0.000000  0.000000   0.00000
  101 1867   TILLCONT.PLACTILL 2  0.000000  0.000000  0.000000   0.00000
  102 1867   TILLRECI.PLACTILL 2 10.772286  5.110514  3.613679  45.91615
  
  
  str(df) :
  
       'data.frame':  1152 obs. of  7 variables:
   $ Year : Factor w/ 156 levels "1855","1856",..: 13 13 13 13 13 13 13 13 14 14 ...
   $ Ratio: Factor w/ 8 levels "TILLBANK...PLACTILL",..: 1 2 3 4 5 6 7 8 1 2 ...
   $ N    : num  2 2 2 2 2 2 2 2 2 2 ...
   $ Mean : num  3.86 21.85 54.2 0 0 ...
   $ sd   : num  4.08 17.86 23.31 0 0 ...
   $ se   : num  2.89 12.63 16.48 0 0 ...
   $ ci   : num  36.7 160.5 209.4 0 0 ...
  </code></pre>
  
  <p><strong>1)</strong> I am doing a <code>ggplot</code>:</p>
  
  <pre><code>qqs&lt;-ggplot(dfccomp, aes(x=Year, y=sd,colour=Ratio))+geom_point()+
      facet_grid(Ratio~.)+
      theme(axis.text.x  = element_text(angle=-90, hjust=0.5, size=11,colour="black"))
  </code></pre>
  
  <p>This plot works with <code>geom_point()</code> but now with <code>geom_line()</code>. If I use <code>geom_point()</code> I then get very messy x-axis with all the years (from 1867 to 2010): 
  <img src="https://i.stack.imgur.com/vNEh0.png" alt="enter image description here"></p>
  
  <p>And if I use <code>geom_line()</code>,which does not work, I get:
  <img src="https://i.stack.imgur.com/EiFt4.png" alt="enter image description here"></p>
  
  <p>So, I wonder how it is possible to only pick some certain years to be present on the x axis?</p>
  
  <p><strong>2)</strong> The other strange thing that I dont understand is if I convert the <code>df$Year</code> above to numeric, </p>
  
  <pre><code>df$Year=as.numeric(as.character(df$Year))
  </code></pre>
  
  <p>Plot is then:
  <img src="https://i.stack.imgur.com/dc2B5.png" alt="enter image description here"></p>
  
  <p>Now, only 3 years are present on the x-axis. Which is better but still not what I want...</p>
  
  <p>why does both <code>geom_point()</code> and <code>geom_line()</code> works?</p>
  
  <p>Updated:
  On the answer below I read that "Year is a factor and as such ggplot() will interpret that accordingly and produce a dotplot. The reason geom_line() doesn't do anything as this geom doesn't make sense for the data supplied; the factor nature indicates to ggplot() that the x-axis is not continuous and there is nothing to draw between points on that axis, hence no lines.". </p>
  
  <p>But I have a different plot where <code>geom_line()</code> works with a factor. Why is it so?</p>
  
  <pre><code>qq&lt;-ggplot(df, aes(x=Year, y=Mean,colour=Ratio)) + 
      geom_errorbar(aes(ymin=Mean-sd, ymax=Mean+sd), colour="black", width=.1, position=position_dodge(.1)) +
      geom_line(position=position_dodge(.1)) +
      geom_point(position=position_dodge(.1), size=3, shape=21, fill="white") + # 21 is filled circle
      xlab("Year") +
      ylab("Mean (%)")+ggtitle("Ratios")+facet_grid(Ratio~.)+theme(axis.text.x  = element_text(angle=-90, hjust=0.5, size=11,colour="black"))
  </code></pre>
  
  <p>The picture:
  <img src="https://i.stack.imgur.com/jzH42.png" alt="enter image description here"></p>