I'm plotting up some data using a ProbabilityScalePlot in Mathematica 8. It currently looks like so:

ProbabilityScalePlot, Automatic Gridlines

Code:

ProbabilityScalePlot[data, "Normal", AspectRatio -> 0.9, Frame -> True, 
    GridLines -> Automatic, GridLinesStyle -> LightGray, Axes -> False, 
    LabelStyle -> font, 
    PlotStyle -> Directive[PointSize -> Large, Thick, Purple], 
    FrameLabel -> {"Value", "Cum. Prob."}, ImageSize -> 250]

I'd like to change the y grid lines to only show up on the ticks {1, 5, 10, 25, 50, 75, 90, 95, 99} but when I change GridLines -> Automatic to GridLines -> {Automatic,Ticks} I get an error.

The error is "A GridLines specification should be None, Automatic, or a list of grid line specifications."

What's odd is that doing the same thing on a different style plot, Histogram for example, works just fine.

Is this a quirk of ProbabilityScalePlot or am I missing something?

If I simplify the input to it's bare-bones (and change the data, sorry):

ProbabilityScalePlot[data, "Normal", GridLines -> {Automatic, Automatic}]

Getting an error...

and then look at the GridLines part of InputForm (formatted and comments added to hopefully make it easier to read):

GridLines ->
    {
     (* X-axis *)
     Charting`ScaledTickValues[
       {#1 & , #1 & },
       Charting`ScaledTickValues[{#1 & , #1 & }][##1]
     ] & ,

     (* Y-axis *)
     Charting`ScaledTickValues[
       {1 + SpecialFunctions`Probit[#1] & ,
        (1*Erfc[(1*(Sqrt[2.] - Sqrt[2.]*#1))/2.])/2. &
       },
       Charting`ScaledTickValues[{#1*0.01 & , #1 & }][##1]
     ] &
    }

It appears that it's correctly assigning something to the x and y axis, but based on the error I assume that it's not evaluating to a list of numbers or grid line specifications. Sadly that InputForm is a bit too complicated for me to read fully, but I can tell that it's using the Z-score of the data point as the actual grid lines or tick marks, but then transforming it to cumulative probability when displaying the y-axis.

  • I didn't read too carefully, but if you know where you want the y-axis gridlines to be, you can manually input them. For example, ProbabilityScalePlot[RandomReal[{0, 1}, {2, 100}], "Normal", AspectRatio -> 0.9, Frame -> True, GridLines -> {Automatic, {1, 5, 10, 25, 50, 75, 90, 95, 99}}, GridLinesStyle -> LightGray, Axes -> False, PlotStyle -> Directive[PointSize -> Large, Thick, Purple], FrameLabel -> {"Value", "Cum. Prob."}, ImageSize -> 500] produces a chart with the gridlines where you want them. Is this what you are looking for? – DumpsterDoofus Jan 21 '15 at 18:21
  • @DumpsterDoofus That doesn't work for me - it reports the "A GridLines specification should be None, Automatic, or a list of grid line specifications" error. I didn't mention it before, but I'm using Mathematica v8 (post updated). – dthor Jan 21 '15 at 18:59
  • 1
    This is a bug in V8 and V9. Fixed in V10. – Mike Honeychurch Jan 21 '15 at 21:02
  • @MikeHoneychurch Awesome, thanks for the info. – dthor Jan 21 '15 at 23:23
  • @Mike I don't think it is fixed in v10, at least not in all cases. Try the examples in dthor's self-answer. The scaling is not handled correctly in the case of negative numbers. – Mr.Wizard Jan 22 '15 at 6:33

A problem still exists with the scaling of grid lines in version 10.0.2. I'll try to explore this later if I have time but for now here is a work-around. Specify the horizontal lines in the plot command and the vertical lines in Show, then combine with Overlay.

gr = ProbabilityScalePlot[data, "Normal", GridLines -> {None, {1, 5, 50, 95, 99}}];

Overlay[{
  gr,
  Show[gr, GridLines -> {{-2, -1, 1, 2, 3}, None}]
}]

enter image description here

As a for-your-information example one must realize that the actual y scale of the Graphics is not what the plot shows:

Show[gr, FrameTicks -> Automatic]

enter image description here

The actual plot range is revealed with;

PlotRange[gr]  (* undocumented usage *)
{{-4.38919, 5.86036}, {-1.4587, 3.4587}}
  • When I was looking at the InputForm for the function, I noticed the PlotRange thing too: Mathematica is using the Z-score (# Std Dev away from mean) as the actual range, but then transforming it to the cumulative probability when displaying. – dthor Jan 22 '15 at 16:30
up vote 2 down vote accepted

Looks like it's a bug:

After more research and test cases, it appears that this is a bug in Mathematica 8. I have no way of checking older or newer versions. Perhaps someone could execute the following test case code and verify?

In Mathematica 8:

The GridLines->{x, y} option of ProbabilityScalePlot does not work as expected under the following circumstances:

+-------------------------------+--------------------------------+
|                               | X GridLine spec has value <= 0 |
+                               +--------------------------------+
|                               |   True       |  False          |
+-------------------------------+--------------+-----------------+
| One or Both GridLine  |  True | No gridlines | Error           |
| specs are "Automatic" |       | displayed;   |                 |
|                       |       | No Error     |                 |
|                       +-------+--------------+-----------------+
|                       | False | No gridlines | OK              |
|                       |       | displayed;   |                 |
|                       |       | No Error     |                 |
+-----------------------+-------+--------------+-----------------+

Go ahead and try out the following Test Cases and see what you get:

First, generate some data from the Normal distribution. The data should have both positive and negative values in order to really see where things freak out.

data = RandomVariate[NormalDistribution[0, 2], 100];

These result in an error:

ProbabilityScalePlot[data, "Normal", GridLines -> {Automatic, Automatic}]
ProbabilityScalePlot[data, "Normal", GridLines -> {Automatic, {1, 2, 3}}]
ProbabilityScalePlot[data, "Normal", GridLines -> {{1, 2, 3}, Automatic}]

These result in no gridlines being displayed and no error thrown:

ProbabilityScalePlot[data, "Normal", GridLines -> {{0, 1, 2, 3}, {1, 5, 50, 95, 99}}]
ProbabilityScalePlot[data, "Normal", GridLines -> {{-1, 1, 2, 3}, {1, 5, 50, 95, 99}}]
ProbabilityScalePlot[data, "Normal", GridLines -> {{0, 1, 2, 3}, Automatic}]

And these test cases work as expected:

ProbabilityScalePlot[data, "Normal", GridLines -> Automatic]
ProbabilityScalePlot[data, "Normal", GridLines -> {None, {1, 5, 50, 95, 99}}]
ProbabilityScalePlot[data, "Normal", GridLines -> {{1, 2, 3}, {10, 50, 95, 99}}]
  • 1
    With V10.0.2 on OS X 10.10.1 I ran all your examples and the first gave a error. The remaining 8 were fine. – Mike Honeychurch Jan 22 '15 at 7:53

ProbabilityScalePlot uses FrameTicks.

data = RandomVariate[NormalDistribution[1, 2], 100];
ProbabilityScalePlot[data, "Normal", 
FrameTicks -> {{Automatic, None}, {Range[-3, 4, .5], None}}]

So if you want to choose your x-axis ticks (here, between -4 and 4 in steps of 0.5), then make the ticks go across the figure in this way:

ProbabilityScalePlot[data, "Normal", 
 FrameTicks -> {Table[{x, x, {.5, 0}}, {x, -4, 4, .5}], Automatic}]

enter image description here

  • It's the lateral gridlines, those associated with Y values, that I'm most interested in. During my search for a solution, I actually found what I think is a bug in ProbabilityScalePlot: try adding the option GridLines->{Automatic, Automatic} - in Mathematica 8, it errors out. – dthor Jan 21 '15 at 20:08
  • I use Mma 10.0.0, so can't check bugs in earlier versions. If there's a true bug, there's not much I can do to help except suggest ugly and awkward combinations of separate plot and grid array figures. Or, of course, compute your own CDFs and plot with a non-buggy plot function. – David G. Stork Jan 21 '15 at 20:09
  • I think it's most definitely a bug. I've already sent Wolfram the bug report. See my Answer for details on the bug, if interested. – dthor Jan 21 '15 at 20:34

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.