2
$\begingroup$

I'd like Legended output for call like:

rcap = {Cos[#], Sin[#]} & ;
p1 = ParametricPlot[{Sin[t] rcap[t], Sin[t]^2 rcap[t]}, {t, 0, Pi},
  PlotRange -> {-1, 1}, AxesLabel -> {x, y}
  , PlotLegends ->
   Placed[{"sin(\[Theta])",
     "\!\(\*SuperscriptBox[\(sin\), \(2\)]\)(\[Theta])"}, {Right,
     Bottom}]
  ]

But have hit the ParametricPlot has PlotLegends bug detailed in ParametricPlot and PlotLegends don't seem to cooperate .

I applied the list of functions answer to my plot (adding expressions for my labels) like so:

x1 = With[{funcList = {Sin[t] rcap[t], Sin[t]^2 rcap[t]},
   labelList = {"sin(\[Theta])",
     "\!\(\*SuperscriptBox[\(sin\), \(2\)]\)(\[Theta])"}
   }, With[{n = Length@funcList},
   Legended[
    ParametricPlot[funcList, {t, 0, Pi}, PlotRange -> {-1, 1},
     AxesLabel -> {x, y}],
    LineLegend[(ColorData[1][#]) & /@ #, labelList[[#]]] &@Range@n]]
  ]

which does successfully include a legend:

capture of image

however, the placement of the legend text is outside of the image. Is there a way to add Placed like options to the Legended function?

$\endgroup$
2
$\begingroup$

From Legended >> Details:

enter image description here

x1 = With[{funcList = {Sin[t] rcap[t], Sin[t]^2 rcap[t]}, 
           labelList = {"sin(\[Theta])", "\!\(\*SuperscriptBox[\(sin\), \(2\)]\)(\[Theta])"}}, 
  With[{n = Length@funcList}, 
   Legended[ParametricPlot[funcList, {t, 0, Pi}, PlotRange -> {-1, 1}, AxesLabel -> {x, y}], 
       Placed[LineLegend[(ColorData[1][#]) & /@ #, labelList[[#]]] &@Range@n, {Right, Bottom}]]]]

enter image description here

You can also use PlotLegends instead of Legended as follows:

x1 = With[{funcList = {Sin[t] rcap[t], Sin[t]^2 rcap[t]}, 
   labelList = {"sin(\[Theta])", "\!\(\*SuperscriptBox[\(sin\), \(2\)]\)(\[Theta])"}}, 
  With[{n = Length@funcList}, 
   ParametricPlot[funcList, {t, 0, Pi}, PlotRange -> {-1, 1}, AxesLabel -> {x, y},
    PlotLegends -> Placed[LineLegend[ColorData[1][#] & /@ Range@n, labelList[[Range@n]]], 
                  {Right, Bottom}]]]]
 (* same picture *)
$\endgroup$
  • $\begingroup$ Thanks. The PlotLegends form is nice. $\endgroup$ – Peeter Joot Jan 19 '15 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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