How to add title to legend in Plots.jl?



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


I don’t think you can. Legends on Plots surely need some love.
For small questions like this, consider using the Gitter channel.


@mkborregaard 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.


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.


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.

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.


My current approach is as follows:

if simple question
  ask on Discourse
  if question has no solution yet
    open an issue on GitHub
  open an issue on GitHub

if issue was reported and time allows
  submit pull request

What is your proposal?

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)
else # not a question, 
  Make a PR 

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


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


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.


what about gitter? :slight_smile:


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:


if hopelessly_confused
    website = if answer_is_useful_to_others
    suggested_action = ask_on(website)
    thank(unpaid_open_source_volunteers) |> profusely
elseif bug || feature_request


For anybody else, the flow chart should instead read

**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!)


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?



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


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.


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