Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Bug introduced in 9.0.1 -- fixed in 10.0.0?

I noted that only part of the legend shows up in ParametricPlot using v9's PlotLegends:

ParametricPlot[{{t, t}, {t, 2 t}}, {t, 0, 1}, PlotLegends -> LineLegend[{1, 2}]]

Mathematica graphics

Inspecting the figure's FullForm gets me (among other things)

   Directive[EdgeForm[GrayLevel[0.5`]], Hue[0.9060679774997897`, 0.6`, 0.6`]]
 ], List[1, 2], 
 Rule[LegendLayout, "Column"]]

It looks like Mathematica forgot to add the second color. Adding the color manually gets me the full legend. This looks like a bug, but perhaps I'm missing something?

I also noticed that virtually all examples in the "Options/PlotLegends" section of the ParametricPlot doc page yield a result differing from the pre-rendered image. Again, this looks like a bug, perhaps introduced by a last-minute addition. I'm using v9.0.1. Anyone with v9.0.0 care to check whether it exists there as well?

share|improve this question
The problem seems to be that the plot legends code is not parsing the first argument to ParametricPlot correctly and identifying the different functions. It incorrectly lists all the terms as a single entry and this can be seen by setting PlotLegends -> "Expressions". In essence, the bug is the equivalent of plotting 2 curves but labeling only 1 (but somewhere inside, the code does know that there are 2 curves, since the line color is pink) –  rm -rf Mar 11 '13 at 23:27
Both legends show as expected in Version 9.0.0 (on Windows Vista 64 bit) –  kguler Mar 11 '13 at 23:42
And legends show as expected if you use this old method with autoLegend... –  Jens Mar 11 '13 at 23:46
@kguler So, as hypothesized, something added in the latest update breaks PlotLegends in this case. –  Sjoerd C. de Vries Mar 13 '13 at 8:40
If you have 10.0.0 installed would you please check to see if this was fixed in that release? –  Mr.Wizard Jan 29 at 10:24

4 Answers 4

up vote 4 down vote accepted

The work-around posted by rcollyer can readily be generalized to work for an arbitrary number of parametric functions.

With[{funcList = {{t, t}, {t, 2 t}, {t, t/2}}},
  With[{n = Length@funcList}, 
    Legended[ParametricPlot[funcList, {t, 0, 1}], 
      LineLegend[(ColorData[1][#])& /@ #, #]& @ Range @ n]]]

enter image description here

share|improve this answer
@kguler gives a nice variation of this in mathematica.stackexchange.com/a/72045/10 that still uses PlotLegends (with Placed), still using LineLegends to workaround the bug as you have done. –  Peeter Joot Jan 22 at 19:18

To flesh out your method, you can do the following

 ParametricPlot[{{t,t},{t,2 t}},{t,0,1}],
 LineLegend[{ColorData[1][1], ColorData[1][2]}, {1, 2}]

enter image description here

which, as noted, requires you to set the color information by yourself. This is the most straightforward workaround.

Incidentally, it is often cleaner to look at the InputForm instead of the FullForm as things like List are not fully expanded. For this, I often use something like this,

Plot[{x^2, x^3}, {x, 0, 1}, PlotLegends -> Automatic] /.
  Legended[_, {p_Placed, ___} | p_Placed]:> InputForm@p[[1]]

 LineLegend[{Directive[Hue[0.67, 0.6, 0.6]], 
  Directive[Hue[0.9060679774997897, 0.6, 0.6]]}, {1, 2}, 
  LegendLayout -> "Column"
share|improve this answer
Apparently, Wolfram tech support was wrong when they told me "there is no good way of working around the problem". –  m_goldberg Mar 13 '13 at 4:12
@m_goldberg This was the line of solution I was hinting at in my question. –  Sjoerd C. de Vries Mar 13 '13 at 8:33
@rcollyer I have the habit of using FullForm because that's the form that will be used in pattern matching, but I agree that InputForm is often much clearer and is preferable when one just wants to see what's going on. –  Sjoerd C. de Vries Mar 13 '13 at 8:35
@m_goldberg don't necessarily blame them, I've been staring at this particular code for quite a while, so I have a good feel for how it works. –  rcollyer Mar 13 '13 at 11:43
@SjoerdC.deVries I had the same habit until I had to start looking at Graphics objects. FullForm would drive you insane pretty quickly. –  rcollyer Mar 13 '13 at 11:46

I queried Wolfram technical support on this issue. Here is their reply:

Our developers are aware that PlotLegends is currently not working well with ParametricPlot. This problem should be fixed in a future version of Mathematica.

Unfortunately, there is no good way of working around the problem with PlotLegends at the current time. If you really need a legend with a ParametricPlot, you might have to use the older PlotLegend function, which is still available in Mathematica.

share|improve this answer
Seems to be fixed in Version 10!? -> link –  Phab Jan 29 at 8:05

As noted by Phab the example in the question works in Mathematica 10.0.2:

ParametricPlot[{{t, t}, {t, 2 t}}, {t, 0, 1}, PlotLegends -> LineLegend[{1, 2}]]

enter image description here

share|improve this answer

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.