r = RandomVariate[NormalDistribution[0, 1], 1500];
custom = NormalDistribution[#, 1] & /@ Range[0, 2, .4];
(* to be replaced with your custom1, custom2, ... *)
You can do one of several things:
Make a single Plot
instead of five separate ones
Show[Histogram[r, Automatic, "PDF"],
Plot[Evaluate[Tooltip[PDF[#, x], #] & /@ custom], {x, -3, 3}]]
(* or Plot[Tooltip[PDF[#, x], #] & /@ custom, {x, -3, 3}, Evaluated -> True] *)
Or provide individual colors in each of Plot
s:
Show[Histogram[r, Automatic, "PDF"],
Plot[Evaluate[Tooltip[PDF[#, x], #]], {x, -3, 3},
PlotStyle -> {Thick, Hue[RandomReal[]]}] & /@ custom]
Block[{i = 1}, Show[Histogram[r, Automatic, "PDF"], With[{j = i++},
Plot[Evaluate[Tooltip[PDF[#, x], #]], {x, -3, 3},
PlotStyle -> {Thick, ColorData[63, "ColorList"][[j]]}]] & /@ custom]]
Update: add legends
Legended[Block[{i = 1},
Show[Histogram[r, Automatic, "PDF"],
With[{j = i++}, Plot[Evaluate[Tooltip[PDF[#, x], #]], {x, -3, 3},
PlotStyle -> {Thick, ColorData[63, "ColorList"][[j]]}]] & /@ custom]],
LineLegend[ColorData[63, "ColorList"][[;; 5]],
{"custom1", "custom2", "custom3", "custom4", "custom5"}]]
Update 2: You can also put everything in a single Plot
using the PDF
of HistogramDistribution
:
hd = HistogramDistribution[r];
custom2 = Prepend[custom, hd];
legendlabels = (Style[#, "Panel", 14] & /@ custom2 /.
DataDistribution[___] :> "HistogramDistribution[r]");
Plot[Tooltip[PDF[#, x], #] & /@ custom2, {x, -3, 3},
LabelStyle -> {16, "Panel", Background -> None}, BaseStyle -> Thick,
PlotStyle -> ColorData[63, "ColorList"], Evaluated -> True, Exclusions -> False,
FillingStyle -> (Lighter@Lighter@ColorData[63, "ColorList"][[1]]),
Filling -> {1 -> Axis}, PlotLegends -> legendlabels]
Another update: Two additional methods with minimal changes in OP's code to add random colors:
Post-process the Line
s to add color directives:
op = Show[Histogram[r, Automatic, "PDF"],
Plot[Evaluate[Tooltip[PDF[#, x], #]], {x, -3, 3}] & /@ custom, ImageSize -> 300];
Row[{op, op /. line : Line[__] :> {Thick, Hue[RandomReal[]], line}}, Spacer[5]]
Use Dynamic
in PlotStyle
options setting:
Show[Histogram[r, Automatic, "PDF"],
Plot[Evaluate[Tooltip[PDF[#, x], #]], {x, -3, 3},
PlotStyle -> Dynamic[Directive[{Thick, Hue[RandomReal[]]}]]] & /@ custom, ImageSize -> 300]
(* similar picture *)