# Want to add a legend to 3D plot made by combining three plots with Show

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]


and I want to a legend of the form

PlotLegends -> SwatchLegend["Expressions"]


How can I do it?

• 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"] – Rahul May 25 '15 at 18:00
• Thanks. It really healped a lot – Vu Panh May 25 '15 at 18:49
• 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. – bbgodfrey Jun 4 '15 at 3:57

## 1 Answer

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)"}]]