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?

  • $\begingroup$ 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) $\endgroup$
    – rm -rf
    Mar 11, 2013 at 23:27
  • $\begingroup$ Both legends show as expected in Version 9.0.0 (on Windows Vista 64 bit) $\endgroup$
    – kglr
    Mar 11, 2013 at 23:42
  • $\begingroup$ And legends show as expected if you use this old method with autoLegend... $\endgroup$
    – Jens
    Mar 11, 2013 at 23:46
  • $\begingroup$ @kguler So, as hypothesized, something added in the latest update breaks PlotLegends in this case. $\endgroup$ Mar 13, 2013 at 8:40
  • $\begingroup$ If you have 10.0.0 installed would you please check to see if this was fixed in that release? $\endgroup$
    – Mr.Wizard
    Jan 29, 2015 at 10:24

4 Answers 4


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

  • $\begingroup$ @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. $\endgroup$ Jan 22, 2015 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"
  • 1
    $\begingroup$ Apparently, Wolfram tech support was wrong when they told me "there is no good way of working around the problem". $\endgroup$
    – m_goldberg
    Mar 13, 2013 at 4:12
  • $\begingroup$ @m_goldberg This was the line of solution I was hinting at in my question. $\endgroup$ Mar 13, 2013 at 8:33
  • $\begingroup$ @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. $\endgroup$ Mar 13, 2013 at 8:35
  • $\begingroup$ @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. $\endgroup$
    – rcollyer
    Mar 13, 2013 at 11:43
  • $\begingroup$ @SjoerdC.deVries I had the same habit until I had to start looking at Graphics objects. FullForm would drive you insane pretty quickly. $\endgroup$
    – rcollyer
    Mar 13, 2013 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.

  • 2
    $\begingroup$ Seems to be fixed in Version 10!? -> link $\endgroup$
    – Phab
    Jan 29, 2015 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

  • $\begingroup$ I arrived at this thread after observing a similar problem in 10.1.0. PlotLegends->Automatic gives up after 15 curves. Fortunately, I can still make the legends show correctly with PlotLegends->LineLegend[Range[n]] for n at least as big as 26. $\endgroup$
    – djphd
    Dec 7, 2015 at 20:20
  • $\begingroup$ @djphd Indeed, that is a known issue. The limitation is not arbitrarily fifteen, but rather the number of colors in the style. Please see (66057) for more. $\endgroup$
    – Mr.Wizard
    Dec 8, 2015 at 1:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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