ggsurv legends and line thickness
<p>I have some problems with the ggsurv function in ggplot.</p>

<p>I want to control the order of appearance with legends and the line style.</p>

<p>I can see that others have similar problems but I dont understand the solution</p>

<p>Using the standard lung data my problem is as</p>

<pre><code>library(GGally)
library(survival)
data(lung)
surv1 &lt;- survfit(Surv(time,status) ~ sex, data = lung)
p1 &lt;- ggsurv(surv1, lty.est=c(1,2), surv.col=c("black", "red" ))
p1 &lt;- p1 + scale_colour_discrete(name = 'sex', breaks = c(1,2), labels=c('XX','XY'))
p1
</code></pre>

<p>Here I would have expected the standard values in the legend replaced with XX and XY. But I get a duplicated legend instead. One with correct line attributes but wrong names and color. Another with correct names and color but wrong line attributes.</p>

<p>I have tried to insert</p>

<pre><code>p1 &lt;- p1 + guides(colour = FALSE)
</code></pre>

<p>but that removes the wrong part of the legend</p>

<p>What do I not understand?</p>

<p>Thanks to cuttlefish's comments a solution is:</p>

<pre><code>library(GGally)
library(survival)
data(lung)
surv1 &lt;- survfit(Surv(time,status) ~ sex, data = lung)
p1 &lt;- ggsurv(surv1, lty.est=c(1,2), surv.col=c("black", "red" ))
p1 &lt;- p1  + scale_colour_discrete(name = 'sex', breaks = c(1,2), labels=c('XX','XY'))
p1 &lt;- p1 + guides(linetype = F, colour = guide_legend(override.aes = list(linetype = c(2,1)))) 
p1
</code></pre>

<p>I can understand that the override.aes manually set the line types used in the legend. I am not fully sure what the linetype = F actually does, but it works!</p>

<p>A second question. How do You manually set the thickness of the lines (both in the graph and the legend)</p>

<p>Adding </p>

<pre><code>p1 &lt;- p1 + geom_line(size=2)
</code></pre>

<p>does not work. It draws ugly black lines which not are fully aligned with the orignal ones. </p>