I want to add legend to Show. I tried as below by the help of how to add plotlegends in a show function:

Show[des = PolarPlot[2 Sin[2 t], {t, 0, 2 Pi}, PlotStyle -> {Gray, Dashed}], 
      Epilog -> Inset[Framed[Column[{PointLegend[{Lighter[Yellow]}, {"Data"}], 
         {"f(x)=\!\(\*SuperscriptBox[\(x\[ExponentialE]\), \\(-x\)]\)"}]}],
         RoundingRadius -> 5], Scaled[{0.8, 0.85}]]]

But the legend comes in the graph. I failed to put it out of the graph. Could anyone help?


2 Answers 2


In such cases, you can treat them as separate objects and combine with Grid

Grid[{{PolarPlot[2 Sin[2 t], {t, 0, 2 Pi}, PlotStyle -> {Gray, Dashed}], 
       Framed[Column[{PointLegend[{Lighter[Yellow]}, {"Data"}], 
        LineLegend[{Darker[Blue]}, {"f(x)=x e^x"}]}], RoundingRadius -> 5]}}]

enter image description here


Eplog does not allow you to rescale the image, so here I do it before with PlotRangePadding

    Show[des = 
  PolarPlot[2 Sin[2 t], {t, 0, 2 Pi}, PlotStyle -> {Gray, Dashed}, 
   PlotRangePadding -> {{0, 4}, 0}], 
 Epilog -> 
    Column[{PointLegend[{Lighter[Yellow]}, {"Data"}], 
         Blue]}, {"f)=\!\(\*SuperscriptBox[\(x\[ExponentialE]\), \
\\(-x\)]\)"}]}], RoundingRadius -> 5], Scaled[{0.72, 0.8}]]]

out =enter image description here

  • $\begingroup$ I think you do not want it to say "f(x)=\!(*SuperscriptBox[(x[ExponentialE]), \(-x)])" right? did you copy it right? there is also an extra opening curly bracket in your code (or one closing to few) $\endgroup$
    – Ruud3.1415
    Commented Jul 19, 2017 at 17:30

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.