Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Version 9 has a new option Legended, which I find appealing since it should allow me to add individual expressions/curves to a legend, but it doesn't seem to be working for expressions in Plot or LogLinearPlot.

For example, I would like to plot $log(x)$ and $x sin(x)$ together but only have $log(x)$ appear in the legend, I try:

LogLinearPlot[{Legended[Log[x], "Log(x)"], x Sin[x]}, {x, 1, 100}]

and the curve for $Log(x)$ just disappears instead of appearing on it's own in the legend. If Legended is not supposed to be used with the "Plot..." family of symbols, then could someone suggest an alternative solution to my problem?

share|improve this question
Yes, that does work for this particular example, because the Log[x] appears first. The complete set of expressions I'm using is a larger than this one and I think the ordering is important since I'm using filling between the curves, which needs to get layered in a particular order (I'll check to see if there's a way I can put all of the legended expressions first). What if I need to put expressions that appear later in the list into the Legend but omit earlier ones? Perhaps I should try to edit my question to include the fact that ordering is important? – Alex May 6 '14 at 7:23
The documentation for Legended states that Legended can be used as a symbolic wrapper for data elements and datasets in functions such as ListPlot and BarChart. So it does appear that it is not intended to work with the Plot* family. – Simon Woods May 6 '14 at 9:15
Ah, ok, thanks Simon. – Alex May 6 '14 at 10:33
@SimonWoods Do you know why LogLinearPlot[{Log[x], x Sin[x], x Cos[x]}, {x, 1, 100}, PlotLegends -> {"Log(x)", None, "x Cos(x)"}] does not work then ? – b.gatessucks May 6 '14 at 10:45
@b.gatessucks, looks like a bug to me. PlotLegends -> LineLegend@{"Log(x)", None, "x Cos(x)"} works though. – Simon Woods May 6 '14 at 11:12
up vote 7 down vote accepted

You can do :

LogLinearPlot[{Log[x], x Sin[x], x Cos[x]}, {x, 1, 100}, 
 PlotLegends -> Placed[{"Log(x)", None, "x Cos(x)"}, After]]

enter image description here

share|improve this answer
Cheers, that works nicely! – Alex May 6 '14 at 10:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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