1
$\begingroup$

I have this code:

PIC1 = Plot3D[Cos[x] Cos[y], {x, -5, 5}, {y, -5, 5}];
PIC2 = 
  Plot3D[-(x - Pi/2) (y + Pi/2), {x, -5, 5}, {y, -5, 5}, 
    ColorFunction -> "DeepSeaColors"];
PIC3 = 
  Plot3D[(x - Pi/2) (y + Pi/2), {x, -5, 5}, {y, -5, 5}, 
    ColorFunction -> "AvocadoColors"];
Show[PIC1, PIC2, PIC3]

enter image description here

and I want to a legend of the form

PlotLegends -> SwatchLegend["Expressions"]

How can I do it?

$\endgroup$
  • $\begingroup$ Why not just put them all in a single plot? Plot3D[{Cos[x] Cos[y], -(x - Pi/2) (y + Pi/2), (x - Pi/2) (y + Pi/2)}, {x, -5, 5}, {y, -5, 5}, PlotRange -> {-1, 1}, ClippingStyle -> None, PlotLegends -> "Expressions"] $\endgroup$ – Rahul May 25 '15 at 18:00
  • $\begingroup$ Thanks. It really healped a lot $\endgroup$ – Vu Panh May 25 '15 at 18:49
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$ – bbgodfrey Jun 4 '15 at 3:57
3
$\begingroup$

Here is a quick and somewhat dirty solution.

Legended[
  Show[PIC1, PIC2, PIC3], 
  SwatchLegend[
    {Yellow, Blue, Green}, {"Cos[x] Cos[y]", 
    "-(x-Pi/2) (y+Pi/2)", "(x-Pi/2) (y+Pi/2)"}]]

plot

$\endgroup$

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.