How to add title to legend in Plots.jl?

question
plotting

#1

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


#2

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


#3

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


#4

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.


#5

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.

#6

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.


#7

My current approach is as follows:

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?


#8
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

#9

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


#10

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.


#11

what about gitter? :slight_smile:


#12

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:

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

#13

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


#14

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


#15

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


#16

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.


#17

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