0
$\begingroup$

I am trying to add a legend to a plot, but sometimes it work and sometimes it doesn't work and I don't understand why. For example, when I use the following code, I get as an error "Unknown option PlotLegend".

Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi}, PlotLegend -> {"sine", "cosine"}]
$\endgroup$

closed as off-topic by Jens, bbgodfrey, rcollyer, Karsten 7., Dr. belisarius Mar 24 '15 at 19:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Jens, bbgodfrey, rcollyer, Karsten 7., Dr. belisarius
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ The option's name is PlotLegends $\endgroup$ – Dr. belisarius Mar 24 '15 at 19:15
4
$\begingroup$

You have a typo in the syntax:

Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi}, PlotLegends -> {"sine", "cosine"}]

You forgot 's' in PlotLegends.

$\endgroup$
  • $\begingroup$ I get the same error both with PlotLegend and PlotLegends. The command PlotLegend exists as well. reference.wolfram.com/language/PlotLegends/ref/PlotLegend.html $\endgroup$ – Lorenzo Mar 24 '15 at 17:35
  • $\begingroup$ The point is that with the same code yesterday it was working. Might it be a problem with libraries? $\endgroup$ – Lorenzo Mar 24 '15 at 17:37
  • $\begingroup$ flic.kr/p/rJJRTh You can see window of my Matematica with difference between PlotLegend and PlotLegends. And on the site, which you gave above, write about Needs["PlotLegends`"] and there're red highlighted misspelling flic.kr/p/rM2Mwp $\endgroup$ – Roman Alexeev Mar 24 '15 at 17:56
  • $\begingroup$ In your case it works. In my case it doesn't work. $\endgroup$ – Lorenzo Mar 24 '15 at 18:01
  • 1
    $\begingroup$ reference.wolfram.com/language/PlotLegends/tutorial/… I suppose we use different versions of Mathematica. Try to add this instruction before use Plot: << PlotLegends` $\endgroup$ – Roman Alexeev Mar 24 '15 at 18:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.