# How to make one legend entry for same colour?

**URL:** <https://discourse.julialang.org/t/how-to-make-one-legend-entry-for-same-colour/44176>\
**Category:** Visualization\
**Created:** [August 3, 2020, 9:06am UTC](https://discourse.julialang.org/t/how-to-make-one-legend-entry-for-same-colour/44176 "2020-08-03T09:06:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HelgavonLichtenstein](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/helgavonlichtenstein/32/5005_2.png) [@HelgavonLichtenstein](https://discourse.julialang.org/u/HelgavonLichtenstein)\
**Post date:** [August 3, 2020, 9:06am UTC](https://discourse.julialang.org/t/how-to-make-one-legend-entry-for-same-colour/44176/1 "2020-08-03T09:06:19Z")

</div>

Is there a way to make one legend entry per colour? I’d like to specify that green represents plants and brown represents nutrients. I am using `Plots.jl`

![image](https://global.discourse-cdn.com/julialang/original/3X/1/2/122a2b5763547e263c422127996d77c004d88beb.png)

MWE

```julia
foo = 1:10; bar = rand(10, 2)
my_plot = plot(foo, bar)
bart = rand(10)
plot!(my_plot, foo, bart,color=1)

```

![image](https://global.discourse-cdn.com/julialang/original/3X/0/f/0f5efe0b55d0b30512b0d9a9330c7fe957792194.png)

So I’d like to have one legend entry for orange and one for blue, even though it plots foo and bart.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [August 3, 2020, 2:21pm UTC](https://discourse.julialang.org/t/how-to-make-one-legend-entry-for-same-colour/44176/2 "2020-08-03T14:21:41Z")

</div>

You could just plot the first line of each colour separately and provide a label, then pass an empty label to subsequent plot calls with that colour:

```julia
plot(1:10, rand(10), color = 1, label = "Blue")
plot!(1:10, rand(10), color = 2, label = "Orange")

for _ in 1:10
    plot!(1:10, rand(10), color = 1, label = "")
end

```

---

<div class="post-metadata">

**Author:** ![Ivan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ivan/32/208442_2.png) [@Ivan](https://discourse.julialang.org/u/Ivan)\
**Post date:** [December 12, 2022, 2:08pm UTC](https://discourse.julialang.org/t/how-to-make-one-legend-entry-for-same-colour/44176/3 "2022-12-12T14:08:33Z")

</div>

Is this still the only way around this?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [December 12, 2022, 3:59pm UTC](https://discourse.julialang.org/t/how-to-make-one-legend-entry-for-same-colour/44176/4 "2022-12-12T15:59:19Z")

</div>

As far as I know it is.
