# How to add title to legend in Plots.jl?

**URL:** <https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018>\
**Category:** Visualization\
**Tags:** question, plotting\
**Created:** [February 10, 2017, 5:46am UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018 "2017-02-10T05:46:05Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [February 10, 2017, 5:46am UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/1 "2017-02-10T05:46:05Z")

</div>

Is it possible? If yes, which backends support it?

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [February 10, 2017, 7:10am UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/2 "2017-02-10T07:10:09Z")

</div>

I don’t think you can. Legends on Plots surely need some love.  
For small questions like this, consider using the Gitter channel. [tbreloff/Plots.jl - Gitter](https://gitter.im/tbreloff/Plots.jl)

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [February 10, 2017, 7:15am UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/3 "2017-02-10T07:15:44Z")

</div>

@mkborregaard isn’t Discourse ideal for keeping these answers public to everyone that searches on Google?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [February 10, 2017, 7:21am UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/4 "2017-02-10T07:21:20Z")

</div>

> [@juliohm](#):
>
> isn’t Discourse ideal for keeping these answers public to everyone that searches on Google?

That’s a good way to store false information. These kinds of simple answers are best in a simple chat, so that way you can be helped to make a PR and fix it. Someone who finds this a few months down the line may be misled.

I highly doubt you will go back and edit this a few months from now when this issue is fixed. Chats don’t have this problem.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [February 10, 2017, 7:39am UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/5 "2017-02-10T07:39:17Z")

</div>

Hi @ChrisRackauckas, why false information? Everything we are discussing here is true, isn’t it?

I don’t like this idea of hiding issues just because a solution is not implemented yet. Besides, I would definitely update my answer in the future if someone pings the topic again. This is why StackOverflow works so well.

My main concerns about Discourse for Julia right now:

1. I cannot mark questions as answered, this is a privilege I don’t have. Only admins decide what is “answerable” in the forum.
2. Every time we post a question about X, we get distracted with Y where Y is some meta discussion about what the forum should contain.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [February 10, 2017, 7:52am UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/6 "2017-02-10T07:52:06Z")

</div>

> [@juliohm](#):
>
> why false information? Everything we are discussing here is true, isn’t it?

At this very instant, yes. If you plan on updating this when it gets implemented, sure. Otherwise, some purity statement about avoiding chats because you want to leave a trail of resources is a silly statement if it’s potentially leaving a trail of bad and incomplete resources. At least Github issues will be closed when the fixes are merged, so a feature request should go there. I think it’s pretty well accepted that feature requests for packages should go at the package repository.

> [@juliohm](#):
>
> Every time we post a question about X, we get distracted with Y where Y is some meta discussion about what the forum should contain.

You did this. @mkborregaard pointed you to the resource where it is recommended to ask this thing (the chatroom or the Plots.jl issues). You asked the meta question and literally asked for my response.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [February 10, 2017, 8:02am UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/7 "2017-02-10T08:02:00Z")

</div>

My current approach is as follows:

```julia
if simple question
  ask on Discourse
  if question has no solution yet
    open an issue on GitHub
  end
else
  open an issue on GitHub
end

if issue was reported and time allows
  submit pull request
end

```

What is your proposal?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [February 10, 2017, 8:17am UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/8 "2017-02-10T08:17:07Z")

</div>

```julia
if I have a question
  Google it first / ask in a chat for guidance
  if question requires discussion
    ask on Discourse
  elseif question is for a solution to a "common" problem
     ask on Stack Overflow
  elseif it's a bug || results in a feature suggestion
    open an issue on GitHub
  else # My question was dumb
    Bury it because no one else needs to read it
    Maybe make a PR to package docs (if necessary)
  end
else # not a question, 
  Make a PR 
end

if issue was reported and time allows
  submit pull request
else
  try to at least give a code or design outline
  try to make bug reports as detailed as possible
end

```

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [February 10, 2017, 8:30am UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/9 "2017-02-10T08:30:23Z")

</div>

Thanks, I’m not sure why discourse was created then, thought it was for  
centralizing all discussions Julia. Anyways, now I know that there is no  
way to set a title for the legend in Plots.jl

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [February 10, 2017, 8:37am UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/10 "2017-02-10T08:37:46Z")

</div>

> [@juliohm](#):
>
> Thanks, I’m not sure why discourse was created then, thought it was forcentralizing all discussions Julia.

A lot of things require a discussion that’s not a bug or feature request. Also, some people might not use Stack Overflow as much. I tend to use it because it shows up better in searches, and a lot more people search there. And this is just my take on it all, YMMV.

Though I highly recommend the PR to docs part: if you are ever confused by docs, right after you learn is the best time to re-write the docs.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [February 10, 2017, 8:55am UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/11 "2017-02-10T08:55:45Z")

</div>

what about gitter? 🙂

---

<div class="post-metadata">

**Author:** ![tbreloff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbreloff/32/68_2.png) [@tbreloff](https://discourse.julialang.org/u/tbreloff)\
**Post date:** [February 10, 2017, 2:24pm UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/12 "2017-02-10T14:24:27Z")

</div>

Remember that posting in Discourse uses the time and focus of many people. The same is true of Gitter, but it’s likely a smaller group of people and the read/response cycle is quicker (which is why we prefer you to ask short questions there).

Even if you go back and change your post, if you fill up future search results with noise (because the question/answer isn’t relevant in the future) then it hurts discoverability in the future.

So I propose this logic when considering a new topic:

```julia
reread(docs)
try_it_yourself()
search(github_issues)
search(google)
try_it_yourself(again)

if hopelessly_confused
    website = if answer_is_useful_to_others
        discourse
    else
        gitter
    end
    suggested_action = ask_on(website)
    do(suggested_action)
    thank(unpaid_open_source_volunteers) |> profusely
elseif bug || feature_request
    try
        submit(PR)
    catch
        file(issue)
        add_to(your_TODO_list)
    end
else
    improve(docs)
    submit(PR)
end

```

---

<div class="post-metadata">

**Author:** ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Post date:** [February 10, 2017, 7:27pm UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/13 "2017-02-10T19:27:42Z")

</div>

For anybody else, the flow chart should instead read

```julia
**if** I have a question
    Google it first / ask in a chat for guidance /
    check if @ChrisRackauckas has already written a blog post about it
...

```

(Thank you for the write ups!)

---

<div class="post-metadata">

**Author:** ![bbrunaud](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bbrunaud/32/1737_2.png) [@bbrunaud](https://discourse.julialang.org/u/bbrunaud)\
**Post date:** [April 5, 2017, 8:00pm UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/14 "2017-04-05T20:00:16Z")

</div>

I respectfully think this discussion is absolutely useless. I had exactly the same question as the person who created the post, and it was useful for me to see the answer right away.

BTW, is there a workaround to get a legend title?

thanks

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [April 5, 2017, 9:06pm UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/15 "2017-04-05T21:06:18Z")

</div>

I don’t think you can. Legends on Plots surely need some love.

---

<div class="post-metadata">

**Author:** ![jebej](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jebej/32/1784_2.png) [@jebej](https://discourse.julialang.org/u/jebej)\
**Post date:** [June 11, 2017, 8:26pm UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/16 "2017-06-11T20:26:33Z")

</div>

I also found this by googling, so +1 from me. Since this post does seem to be indexed now, it will be worth it to update it when (if) legend labels become available.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [June 12, 2017, 9:32am UTC](https://discourse.julialang.org/t/how-to-add-title-to-legend-in-plots-jl/2018/17 "2017-06-12T09:32:56Z")

</div>

The functionality is now available (for the GR and PyPlot backends only at the moment) - the keyword is `legendtitle`.
