4
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"]

Plot1 Plot2 Plot3

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

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

Plot

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

Sektor
  • 3,320
  • 7
  • 27
  • 36
Steve
  • 1,407
  • 10
  • 16
  • 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 06 '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 06 '13 at 21:02
  • This is simply how it works ;) http://mathematica.stackexchange.com/a/129/5478. Also take a look at Show in documentation especially on the Possible issues – Kuba Sep 06 '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 07 '13 at 20:23

2 Answers2

6

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:

plot

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
  • 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 07 '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 07 '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 07 '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 07 '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 07 '13 at 21:28
  • @Steve It seems you have not checked links I put under your question. Please focus on Show>PossibleIssues in documentation center. ProbabilityScalePlot creates dashed line by putting it in the Epilog, which is an option, and Show cares only about first element options. That's why I've said that creating this line is a strange design, maybe for other purpose which we do not know, but still, it works well in terms of relations Show<->Options. – Kuba Sep 07 '13 at 21:33
  • @Steve See this example in the Documentation: Show uses the options from the first graphic. – Alexey Popkov Sep 07 '13 at 21:34
  • @AlexeyPopkov You know what I'm curious about? Where is the information about dashing? Also, with Options[plot1,Epilog] the part with Line[...] appears marked in red color. Do you see it too? – Kuba Sep 07 '13 at 21:38
  • @Kuba Yes, it is how FrontEnd (which follows undocumented preprocessing by the kernel which is based on MakeBoxes) interprets the styling specification. Use InputForm@Options[plot1, Epilog] to get rid of undesired interpretation. – Alexey Popkov Sep 07 '13 at 21:44
  • Thank you, I wasn't aware of that :) – Kuba Sep 07 '13 at 21:46
  • @Kuba Just for illustration of the underlying behavior try Options[plot1, Epilog] /. Style -> style. :) – Alexey Popkov Sep 07 '13 at 21:50
  • I love this forum, I wouldn't know 10% of what I know about MMA without it :) Each day something new :) – Kuba Sep 07 '13 at 21:54
  • @Kuba Another fun may be Options[plot1, Epilog] /. Style -> "Style". It mimics InputForm in this particular case without converting everything to String. Another way is changing the context: Options[plot1, Epilog] /. Style -> My`Style. I have generalized this idea some time ago here. – Alexey Popkov Sep 07 '13 at 22:02
  • @AlexeyPopkov Sometimes it is enough to click on the output and type something. But here nothing showed so I thought it is ordinary syntax mark. :) – Kuba Sep 07 '13 at 22:04
  • @Kuba You can convert the Cell to InputForm by right-clicking on the cell bracket and selecting Convert To -> InputForm. You will find something undocumented in this particular case (and it was already discussed on this forum). – Alexey Popkov Sep 07 '13 at 22:08
  • @AlexeyPopkov I know this, I just wasn't aware that there is something more inside this time :) – Kuba Sep 07 '13 at 22:10
  • @AlexeyPopkov thank you guys, I see now that the options do matter as a "Possible Issue" as shown in the PolarPlot example. Because each of my reference lines has a different color and pair of endpoints are these differences the cause of the Options being different ? If so, I would have thought that the presence or absence of the line itself or some other intentional user edit of an option would be required for a difference to be picked up by Mathematica. – Steve Sep 07 '13 at 22:21
1

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]

enter image description here

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.

Kuba
  • 136,707
  • 13
  • 279
  • 740