# How to add colors and legends to plots with "Show" [duplicate]

I have lets say three plots A, B, C. I know that in order to plot them on top of each other I can use Show function and it will show them all together, Is there a way to change the color (and/or legend) of the plots within the Show command? without going back to the original Plot for each A, B and C and changing the color and legend.

I tried something like this

Show[{A, PlotStyle -> Black}, {B, PlotStyle -> Red}, {C, PlotRange -> Pink}]


But i got an error (Show::gcomb: Could not combine the graphics objects in ).

• Put PlotStyle -> correspondingstyle as option in each plot, and then use Show[A,B,C] Jan 30, 2020 at 18:56
• @Fraccalo while this is what I would have suggested as well, I think that Erf does not want to go back to the individual plots and if I understand the solution has to be at the level of Show
– kcr
Jan 30, 2020 at 19:00
• That is true @Darth_Bane , I don't want to go back to the each plot,
– Erf
Jan 30, 2020 at 19:02
• sorry didn't read properly, see answer below. Jan 30, 2020 at 19:12

a = Plot[x, {x, 0, 2}];
b = Plot[x^2, {x, 0, 2}];
c = Plot[x^3, {x, 0, 2}];

defaultMMAcolor=RGBColor[0.368417, 0.506779, 0.709798]

Show[a /. {defaultMMAcolor -> Black},
b /. {defaultMMAcolor -> Red},
c /. {defaultMMAcolor -> Pink}]


Is this something that you had in mind?

Generate a random plot

A = Plot[x^3, {x, -3, 3}]


And then

Show[A /. _RGBColor -> Red]


The above is the simplest resolution I know off and I have used in the past. I found this answer on this site. I am giving the link, where you can also find more sophisticated approaches you can check

Regarding the question at the comment: is the following acceptable?

Legended[Show[A /. _RGBColor -> Red], Placed[SwatchLegend[{Red, Green, Blue},
{"something"}], {1, 1}]]

• the problem with this approach is that it changes all the colors: say for example your plot is: a = Plot[x, {x, 0, 2}, AxesStyle -> Green]; with your code the axes color would be overwritten to Red Jan 30, 2020 at 19:16
• @Fraccalo that is a valid point. I did not know that because I don't change the colours of the axes. Thanks for pointing it out anyway
– kcr
Jan 30, 2020 at 19:19
• @Darth_Bane thank you, this actually works. But do you know how to add legends in similar way ?
– Erf
Jan 30, 2020 at 19:21
• @Erf I just want to point out that the other answer is better and more precise and I have voted for it. Just to be clear
– kcr
Jan 30, 2020 at 19:23
• @Erf while I still suggest that you try the other answer as it is more complete, I think I have answered the PlotLegends comment. please have a look
– kcr
Jan 30, 2020 at 19:31