# Extract coordinates from QQ Plot

**URL:** <https://forum.certara.com/t/extract-coordinates-from-qq-plot/2909>\
**Category:** Phoenix WNL basics\
**Created:** [November 11, 2015, 2:58pm UTC](https://forum.certara.com/t/extract-coordinates-from-qq-plot/2909 "2015-11-11T14:58:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Helmut\_Schuetz](https://avatars.discourse-cdn.com/v4/letter/h/eb8c5e/32.png) [@Helmut\_Schuetz](https://forum.certara.com/u/Helmut_Schuetz)\
**Post date:** [November 11, 2015, 2:58pm UTC](https://forum.certara.com/t/extract-coordinates-from-qq-plot/2909/1 "2015-11-11T14:58:05Z")

</div>

Hi to all,

I would like to flag potential outliers in a QQ Plot. The check box ‘Display Data Labels’ isn’t very helpful, but at least I could conform that PHX calculates correctly. 😉  
My first idea was to split the data and overlay the ‘normal’ ones with the ‘potential oulier’. Unfortunately adding plots are nor possible (and in Box Plots as well)…

Are there any means to extract the x-coordinates? If yes; I could go with an XY Plot. I don’t want to go with R, since not everybody has a Connect license. 😉  
Example code in R what I would like to achieve:

```auto
StdRes <- c(+0.1751, +0.0538, +1.4321, +0.3130, +0.3558, -1.5904,
            -0.9096, -0.9735, -0.7815, +1.2935, -0.3438, -0.4224,
            +0.7162, +0.3140, -1.0118, +1.3558, -0.2965, -0.5263,
            +1.3903, +0.3488, +2.2361, -0.5805, -0.8683, -1.6799)
QQdata <- qqnorm(StdRes, plot.it=FALSE)
PO     <- which(QQdata$y >= 1.96) # potential outliers
plot(QQdata, main="Q-Q Plot", las=1,
  xlab="Standard Normal Quantiles",
  ylab="Studentized Residuals", cex=1.5, pch=21,
  col="blue", bg="lightblue")
qqline(StdRes, col="blue", lwd=2)
points(QQdata$x[[PO]], QQdata$y[[PO]], cex=1.5, pch=21,
  col="red", bg="gold")

```

---

<div class="post-metadata">

**Author:** ![Helmut\_Schuetz](https://avatars.discourse-cdn.com/v4/letter/h/eb8c5e/32.png) [@Helmut\_Schuetz](https://forum.certara.com/u/Helmut_Schuetz)\
**Post date:** [November 13, 2015, 3:21am UTC](https://forum.certara.com/t/extract-coordinates-from-qq-plot/2909/2 "2015-11-13T03:21:24Z")

</div>

OK, I’ll reply to myself. It’s similar to pre-6.4 when the inverse Chi-distribution was not available in a custom transformation. This time we would need the inverse standard normal. It’s available deep in the guts of Phoenix (otherwise the QQ Plots would not be possible) but not accessible to us mere mortals.

I setup a (clumsy) workflow. First we need the p-values. Easy. Next a numeric approximation. I found one by Peter J. Acklam: _An algorithm for computing the inverse normal cumulative distribution function_ ([http://home.online.no/~pjacklam/notes/invnorm/index.html](http://home.online.no/~pjacklam/notes/invnorm/index.html)). I compared it to R and bloody Excel. Not that bad. Since I only want it for a plot, I didn’t care too much.

See the attached project. In my “annotated QQ Plot” I rounded the normal quantiles in order to get ‘pretty’ data labels. If you are more interested in accuracy, switch them off and map ‘x’ instead of ‘Rounded\_x’.

[InvStandNorm.phxproj](https://forum.certara.com/uploads/short-url/a5b7GCwrqzMu7Q3MplAWqfTgpi4.phxproj) (987 KB)

---

<div class="post-metadata">

**Author:** ![SimonDavis](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@SimonDavis](https://forum.certara.com/u/SimonDavis)\
**Post date:** [November 16, 2015, 10:41am UTC](https://forum.certara.com/t/extract-coordinates-from-qq-plot/2909/3 "2015-11-16T10:41:00Z")

</div>

thanks Helmut, for your work here - looks interesting and I’ll discuss with the Product team what enhancements we can implement to improve i.e.

1. Add inverse standard normal

2. Display possible outliers in QQ plot

Simon.

---

<div class="post-metadata">

**Author:** ![Helmut\_Schuetz](https://avatars.discourse-cdn.com/v4/letter/h/eb8c5e/32.png) [@Helmut\_Schuetz](https://forum.certara.com/u/Helmut_Schuetz)\
**Post date:** [November 16, 2015, 6:51pm UTC](https://forum.certara.com/t/extract-coordinates-from-qq-plot/2909/4 "2015-11-16T18:51:58Z")

</div>

Hi Simon,

> [@sdavis](#):
>
> […] I’ll discuss with the Product team what enhancements we can implement to improve i.e.
> 
> 1. Add inverse standard normal
> 
> 2. Display possible outliers in QQ plot

I think #1 is more important. #2 would require adding a second graph to QQ Plot. Might be not that easy.
