The ggplot2 version of plot.sharp_scan(), with the same information: the
sharp identified set as a filled band with solid edges, the outer band
(without the cap \(\pi \le 1\)) dashed, the confidence set dotted where
the scan has one, the point that a model on the observed rows asserts
(\(\lambda = 0\)), and, if the scan has a threshold, the decision
threshold with a drop line and a label where the set first reaches it.
Where the cap \(\pi \le 1\) holds an edge of the set flat from some
\(\lambda\) on (see held in sharp_scan()), a diamond on that edge
marks where, and the legend gives the value.
Arguments
- object
A
"sharp_scan"object: fromsharp_scan(),sharp_scan_mean(),sharp_scan_ci(),sharp_scan_mean_ci(),sharp_scan_contrast()orsharp_scan_mean_contrast().- scale
"ratio"(default) puts \(e^\lambda\) on the horizontal axis,"log"puts \(\lambda\), as inplot.sharp_scan().- colors
Named colours
sharpandnaive, as inplot.sharp_scan().- text_col
Colour for text and reference lines.
- xlab, ylab, main
Axis labels and title;
NULLgives the same defaults asplot.sharp_scan().+ ggplot2::labs()works too.- ...
Not used.
Details
The legend sits below the panel. The result is an ordinary ggplot object:
add layers, scales, labs() or a theme() to it as usual. The methods are
registered for ggplot2::autoplot() when ggplot2 is loaded; ggplot2 is not
required to install or use the rest of the package.
The curve layers carry their data in long form: layer_data() or
p$layers[[i]]$data gives lambda, the horizontal position x, the value
y, the series ("sharp", "naive", "ci") and the edge.
See also
plot.sharp_scan() for base graphics.
Examples
if (requireNamespace("ggplot2", quietly = TRUE)) {
library(ggplot2)
d <- simulate_shadow(5000, tilt = -1, seed = 1)
rej <- d[d$observed == 0, ]
s <- sharp_scan(rej$eta_obs, rej$obs_rate, threshold = 0.35)
autoplot(s)
autoplot(s, scale = "log") + theme_minimal()
}
