# Why are reference lines missing in ProbabilityScalePlot when using Show?

failurevalues1 = {21, 19., 23., 22., 20., 28., 25.};
failurevalues2 = {30., 28., 28., 29., 31., 28., 30.};
failurevalues3 = {344., 552., 326., 267., 382., 301., 354.};

plot1 = ProbabilityScalePlot[failurevalues1, "LogNormal",
PlotRange -> {{10, 1000}, {1, 99}}, PlotStyle -> Red, Frame -> True,
FrameLabel -> {"Number of Cycles", "CDF"}, PlotLabel -> "Plot 1"]

plot2 = ProbabilityScalePlot[failurevalues2, "LogNormal",
PlotRange -> {{10, 1000}, {1, 99}}, PlotStyle -> Black,
Frame -> True, FrameLabel -> {"Number of Cycles", "CDF"},
PlotLabel -> "Plot 2"]

plot3 = ProbabilityScalePlot[failurevalues3, "LogNormal",
PlotRange -> {{10, 1000}, {1, 99}}, PlotStyle -> Blue,
Frame -> True, FrameLabel -> {"Number of Cycles", "CDF"},
PlotLabel -> "Plot 3"]


So far, so good. The individual plots look reasonable.

plot4 = Show[plot1, plot2, plot3, PlotLabel -> "Plot Comparison"]


Here is the problem, why is only 1 reference line shown in plot4 ? How can I display the 2 missing reference lines ?

-
It is related to the fact that Show takes only first argument's options. In this case plot1's but I don't know which option is the reason. – Kuba Sep 6 '13 at 20:33
As near as I can tell each of the 3 individual plots all have the same options regarding the display of their respective reference lines. So shouldn't Show render these plots in a combined graphics element just as they appear individually ? Why would only 2 of the 3 reference lines be rendered ? – Steve Sep 6 '13 at 21:02
This is simply how it works ;) mathematica.stackexchange.com/a/129/5478. Also take a look at Show in documentation especially on the Possible issues – Kuba Sep 6 '13 at 21:12
@Steve These 3 individual plots do not have the same options regarding the display of their respective reference lines. You can see it with InputForm[Epilog /. Options[#, Epilog]] & /@ {plot1, plot2, plot3}. Epilog is an option of Graphics and, of course, of any plotting function like Plot or ProbabilityScalePlot! – Alexey Popkov Sep 7 '13 at 20:23

Looking at InputForm of ProbabilityScalePlot[...] reveals that the dashed line is drawn by Epilog and therefore is dropped for all such plots except first when they are combined using Show. It is clearly wrong design or a bug. The workaround is to Append the Epilog to the first argument of Graphics produced by ProbabilityScalePlot (which contains all the graphics primitives included in the figure with except to those defined by the Prolog and Epilog options). Here is a fix for ProbabilityScalePlot:

pspFix = Graphics[Append[First@#, Epilog /. Options[#, Epilog]],
FilterRules[Options[#], Except[Epilog]]] &;
SetOptions[ProbabilityScalePlot, DisplayFunction -> pspFix];


You can include it in init.m file.

After evaluating the above, reevaluating the code in question produces expected result:

-
Alexey, thank you for your solution, I don't understand it all but it works. I don't know what is going on but this is the 2nd bug in Mathematica I identified this year alone and I am by no means a power user. The other bug was also associated with version 9. I've been using this tool off and on since version 2.2 and these are the only bugs I've personally identified. – Steve Sep 7 '13 at 14:33
@Steve It could be unexpected but it is not a bug. ProbabilityScalePlot creates this dashed line via Epilog, that's why Show skip some of them. I don't know why Probability... works this way but that the different question. – Kuba Sep 7 '13 at 19:00
@Kuba It is apparent inconsistency. Isn't it a bug? Or just wrong desing? It is not the expected behavior certainly. – Alexey Popkov Sep 7 '13 at 20:14
@AlexeyPopkov It depends on the definition of bug, definitely it is not expected. I would rather say that it is strange design, but maybe it has some purpose, I don't know. – Kuba Sep 7 '13 at 20:46
@Kuba I'm probably missing something here but why are the options in ProbabilityScalePlot particularly relevant ? Isn't it the job of Show to overlay the graphic elements no matter what the options are for the individual elements? From the documentation: Show . . . " concatenates the graphics primitives in the Subscript[g, i], effectively overlaying the graphics." But in the example above the graphics are not being overlaid; some are altered then they are overlaid. Is this by design ? – Steve Sep 7 '13 at 21:28

I do not know which option is responsibile for the dashed line so let me show you brute force approach since it is too late to think :)

It involves Overlay:

i = 0;
Overlay[
ProbabilityScalePlot[#, "LogNormal", PlotRange -> {{10, 1000}, {1, 99}},
PlotStyle -> (++i; {Red, Green, Blue}[[i]]),
BaseStyle -> {15, PointSize@.02}, Frame -> True,
FrameLabel -> {"Number of Cycles", "CDF"},
PlotLabel -> "Plot Comparison", ImageSize -> 500

] & /@ {failurevalues1, failurevalues2,  failurevalues3}
, All]


Labels and Ticks look quite sharp because of not perfect alignment.

You can avoid it.

Just specify PlotLabel for one plot and FrameTicks->None for others. But add consistent PlotRangePadding so the frame will fit for all of them.

-