Customize x-axis ticks with scale_x_discrete and scale_x_continuous
<p>I wanted to have my ticks on x-axis looking like this(but no dash needed)</p>

<p>3(12)  -  5(20)   -   7(28)  -  9(36)   -   11(44)   -   13(52)</p>

<p>The original graph is </p>

<p><a href="https://i.stack.imgur.com/ryw3i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ryw3i.png" alt="enter image description here"></a></p>

<p>made with</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>  n.clusters mean.cluster mean.bucket   variable    value
1           3     21.64790    21.49858 sd.cluster 5.643380
2           5     21.63516    21.54975 sd.cluster 4.369756
3           7     21.55446    21.49889 sd.cluster 3.643280
4           9     21.59585    21.57022 sd.cluster 3.237870
5          11     21.63110    21.58452 sd.cluster 3.012060
6          13     21.55224    21.56104 sd.cluster 2.643777
7           3     21.64790    21.49858  sd.bucket 5.648886
8           5     21.63516    21.54975  sd.bucket 4.397690
9           7     21.55446    21.49889  sd.bucket 3.654752
10          9     21.59585    21.57022  sd.bucket 3.262954
11         11     21.63110    21.58452  sd.bucket 3.023834
12         13     21.55224    21.56104  sd.bucket 2.716441</code></pre>
</div>
</div>
</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>ggplot(data, aes(n.clusters, value, shape=variable, group=variable)) + 
  geom_line(size = 1) +
  geom_point(size = 3.5) +
  scale_x_continuous(breaks = seq(1, 13, 2)) +
  scale_shape_discrete(solid=F,
                       name = "Variable",
                       breaks = c("sd.cluster", "sd.bucket"),
                       labels = c("sd.cluster", "sd.bucket")) +
  theme_bw() +
  theme(axis.text=element_text(size=16),
        axis.title=element_text(size=16,face="bold")) +
  labs(x = "Number of cluster",
       y = "Value")</code></pre>
</div>
</div>
</p>

<p>As referred to these links, I made some changes in the code
 <a href="https://github.com/hadley/ggplot2/issues/501" rel="nofollow noreferrer">https://github.com/hadley/ggplot2/issues/501</a></p>

<p><a href="https://stackoverflow.com/questions/13850329/customizing-x-axis-of-ggplot-graph">Customizing x-axis of graph</a></p>

<p>and got these at best but not resulted what I wanted.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>ggplot(data = mu.est.summary.long, aes(n.clusters, value, shape=variable, group=variable)) + 
  geom_line(size = 1) +
  geom_point(size = 3.5) +
  scale_x_discrete(breaks = c("3","5","7","9","11","13"),
                   labels = c("3(12)", "5(20)", "7(28)", "9(36)", "11(44)", "13(52)") +
  scale_shape_discrete(solid=F,
                       name = "Variable",
                       breaks = c("sd.cluster", "sd.bucket"),
                       labels = c("sd.cluster", "sd.bucket")) +
  theme_bw() +
  theme(axis.text=element_text(size=16),
        axis.title=element_text(size=16,face="bold")) +
  labs(x = "Number of cluster",
       y = "Value")</code></pre>
</div>
</div>
</p>

<p>Within <code>scale_x_discrete</code>:
Using neither <code>limits=c(levels(n.clusters$data)</code> nor <code>breaks=c()</code> nor <code>breaks= seq()</code> didn't work. R keeps saying that something is missing... What did I miss?</p>

<p>Thanks for any help.</p>