<p>You don't have any continuous fill scales, since you're filling according to <code>Condition</code>, which is a factor. This is leading to the <code>Error: Discrete value supplied to continuous scale</code> error. You just need to combine your previous <code>scale_fill_manual(values=...)</code> command with the <code>labels=</code> part of your incorrect <code>scale_fill_continuous()</code> command:</p>

<pre><code>ggplot(dataset, aes( x = Norm, fill = Condition, y=log2(measure))) +
    geom_boxplot() +
    scale_fill_manual(values=c("brown1","darkolivegreen4","burlywood3"),
                      labels = paste("condition1", "condition2", "condition3")) +
    theme_classic() + 
    labs(title="Comparison",x="Norm", y = "counts")
</code></pre>

<p>Something along those lines should work.</p>

CC BY-SA 3.0
2018-03-13T14:27:52.213Z
2018-03-13T14:27:52.213Z
Devon Ryan
<pre><code>ggplot(dataset, aes( x = Norm, fill = Condition, y=log2(measure))) + geom_boxplot() +
        scale_fill_manual(values=c("brown1","darkolivegreen4","burlywood3")) + theme_classic() + 
        labs(title="Comparison",x="Norm", y = "counts") +
        scale_fill_continuous(labels = paste("condition1", "condition2", "condition3"))
</code></pre>

<p>I am trying to change the labels of the legend. Currently, it shows the labels that are present in my dataset. However, I want to change it to "condition1", "condition2", "condition3". Above is the code I am trying. It gives me following error.</p>

<pre><code>Scale for 'fill' is already present. Adding another scale for 'fill', which will replace the existing scale. Error: Discrete value supplied to continuous scale In addition: Warning message: Removed 18 rows containing non-finite values (stat_boxplot).
</code></pre>

<p>Could someone help me here?</p>

CC BY-SA 3.0
2018-03-13T14:34:31.553Z
I'm voting to close this question as off-topic because it is not about bioinformatics. Also this problem is answered in Stack Overflow
llrs
<r><ggplot2>
Changing the legend names
# Changing the legend names

(Asked by: username_0 on 2018-03-13)

ggplot(dataset, aes( x = Norm, fill = Condition, y=log2(measure))) + geom_boxplot() +
        scale_fill_manual(values=c("brown1","darkolivegreen4","burlywood3")) + theme_classic() + 
        labs(title="Comparison",x="Norm", y = "counts") +
        scale_fill_continuous(labels = paste("condition1", "condition2", "condition3"))

I am trying to change the labels of the legend. Currently, it shows the labels that are present in my dataset. However, I want to change it to "condition1", "condition2", "condition3". Above is the code I am trying. It gives me following error.
Scale for 'fill' is already present. Adding another scale for 'fill', which will replace the existing scale. Error: Discrete value supplied to continuous scale In addition: Warning message: Removed 18 rows containing non-finite values (stat_boxplot).

Could someone help me here?

**Tags:** r, ggplot2
> **Comments:**
> **username_1**: I'm voting to close this question as off-topic because it is not about bioinformatics. Also this problem is answered in Stack Overflow  

---

## 1 answers

### Answer by username_2 on 2018-03-13. Score: 5 | Accepted answer

You don't have any continuous fill scales, since you're filling according to Condition, which is a factor. This is leading to the Error: Discrete value supplied to continuous scale error. You just need to combine your previous scale_fill_manual(values=...) command with the labels= part of your incorrect scale_fill_continuous() command:
ggplot(dataset, aes( x = Norm, fill = Condition, y=log2(measure))) +
    geom_boxplot() +
    scale_fill_manual(values=c("brown1","darkolivegreen4","burlywood3"),
                      labels = paste("condition1", "condition2", "condition3")) +
    theme_classic() + 
    labs(title="Comparison",x="Norm", y = "counts")

Something along those lines should work.


---

