<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><meta name="description" content='"Meta" stat for computing distribution functions (densities or CDFs) + intervals for use with
geom_slabinterval(). Useful for creating eye plots, half-eye plots, CCDF bar plots,
gradient plots, histograms, and more. Sample data can be supplied to the x and y
aesthetics or analytical distributions (in a variety of formats) can be supplied to the
xdist and ydist aesthetics.
See Details.'><title>Slab + interval plots for sample data and analytical distributions (ggplot stat) — stat_slabinterval • ggdist</title><!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png"><link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png"><link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png"><link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png"><link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png"><link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png"><script src="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link href="../deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet"><script src="../deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="../deps/Source_Sans_Pro-0.4.8/font.css" rel="stylesheet"><link href="../deps/Source_Code_Pro-0.4.8/font.css" rel="stylesheet"><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous"><!-- bootstrap-toc --><script src="https://cdn.jsdelivr.net/gh/afeld/bootstrap-toc@v1.0.1/dist/bootstrap-toc.min.js" integrity="sha256-4veVQbu7//Lk5TSmc7YV48MxtMy98e26cf5MrgZYnwo=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- search --><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.jquery.min.js" integrity="sha512-GU9ayf+66Xx2TmpxqJpliWbT5PiGYxpaG8rfnBEk1LL8l1KGkRShhngwdXK1UgqhAzWpZHSiYPc09/NwDQIGyg==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js" integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww==" crossorigin="anonymous"></script><!-- pkgdown --><script src="../pkgdown.js"></script><meta property="og:title" content="Slab + interval plots for sample data and analytical distributions (ggplot stat) — stat_slabinterval"><meta property="og:description" content='"Meta" stat for computing distribution functions (densities or CDFs) + intervals for use with
geom_slabinterval(). Useful for creating eye plots, half-eye plots, CCDF bar plots,
gradient plots, histograms, and more. Sample data can be supplied to the x and y
aesthetics or analytical distributions (in a variety of formats) can be supplied to the
xdist and ydist aesthetics.
See Details.'><meta property="og:image" content="http://mjskay.github.io/ggdist/logo.svg"><!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]--><!-- Global site tag (gtag.js) - Google Analytics --><script async src="https://www.googletagmanager.com/gtag/js?id=UA-93322-5"></script><script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-93322-5');
</script></head><body>
    <a href="#main" class="visually-hidden-focusable">Skip to contents</a>
    

    <nav class="navbar fixed-top navbar-light navbar-expand-lg bg-light"><div class="container">
    
    <a class="navbar-brand me-2" href="../index.html">ggdist</a>

    <small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.3.2</small>

    
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div id="navbar" class="collapse navbar-collapse ms-3">
      <ul class="navbar-nav me-auto"><li class="active nav-item">
  <a class="nav-link" href="../reference/index.html">Reference</a>
</li>
<li class="nav-item dropdown">
  <a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true" id="dropdown-articles">Articles</a>
  <div class="dropdown-menu" aria-labelledby="dropdown-articles">
    <a class="dropdown-item" href="../articles/dotsinterval.html">Dots + interval stats and geoms</a>
    <a class="dropdown-item" href="../articles/freq-uncertainty-vis.html">Frequentist uncertainty visualization</a>
    <a class="dropdown-item" href="../articles/lineribbon.html">Lineribbon stats and geoms</a>
    <a class="dropdown-item" href="../articles/slabinterval.html">Slab + interval stats and geoms</a>
    <a class="dropdown-item" href="../articles/thickness.html">Thickness scale</a>
  </div>
</li>
<li class="nav-item">
  <a class="nav-link" href="../news/index.html">Changelog</a>
</li>
      </ul><form class="form-inline my-2 my-lg-0" role="search">
        <input type="search" class="form-control me-sm-2" aria-label="Toggle navigation" name="search-input" data-search-index="../search.json" id="search-input" placeholder="Search for" autocomplete="off"></form>

      <ul class="navbar-nav"><li class="nav-item">
  <a class="external-link nav-link" href="https://github.com/mjskay/ggdist/" aria-label="github">
    <span class="fab fa fab fa-github fa-lg"></span>
     
  </a>
</li>
      </ul></div>

    
  </div>
</nav><div class="container template-reference-topic">
<div class="row">
  <main id="main" class="col-md-9"><div class="page-header">
      <img src="../logo.svg" class="logo" alt=""><h1>Slab + interval plots for sample data and analytical distributions (ggplot stat)</h1>
      <small class="dont-index">Source: <a href="https://github.com/mjskay/ggdist/blob/HEAD/R/stat_slabinterval.R" class="external-link"><code>R/stat_slabinterval.R</code></a></small>
      <div class="d-none name"><code>stat_slabinterval.Rd</code></div>
    </div>

    <div class="ref-description section level2">
    <p>"Meta" stat for computing distribution functions (densities or CDFs) + intervals for use with
<code><a href="geom_slabinterval.html">geom_slabinterval()</a></code>. Useful for creating eye plots, half-eye plots, CCDF bar plots,
gradient plots, histograms, and more. Sample data can be supplied to the <code>x</code> and <code>y</code>
aesthetics or analytical distributions (in a variety of formats) can be supplied to the
<code>xdist</code> and <code>ydist</code> aesthetics.
See <strong>Details</strong>.</p>
    </div>

    <div class="section level2">
    <h2 id="ref-usage">Usage<a class="anchor" aria-label="anchor" href="#ref-usage"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">stat_slabinterval</span><span class="op">(</span></span>
<span>  mapping <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  data <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  geom <span class="op">=</span> <span class="st">"slabinterval"</span>,</span>
<span>  position <span class="op">=</span> <span class="st">"identity"</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  p_limits <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="cn">NA</span>, <span class="cn">NA</span><span class="op">)</span>,</span>
<span>  density <span class="op">=</span> <span class="st">"bounded"</span>,</span>
<span>  adjust <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/waiver.html" class="external-link">waiver</a></span><span class="op">(</span><span class="op">)</span>,</span>
<span>  trim <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>  expand <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  breaks <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/waiver.html" class="external-link">waiver</a></span><span class="op">(</span><span class="op">)</span>,</span>
<span>  align <span class="op">=</span> <span class="st">"none"</span>,</span>
<span>  outline_bars <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  point_interval <span class="op">=</span> <span class="st">"median_qi"</span>,</span>
<span>  slab_type <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  limits <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  n <span class="op">=</span> <span class="fl">501</span>,</span>
<span>  .width <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">0.66</span>, <span class="fl">0.95</span><span class="op">)</span>,</span>
<span>  orientation <span class="op">=</span> <span class="cn">NA</span>,</span>
<span>  na.rm <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  show.legend <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span>size <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span>,</span>
<span>  inherit.aes <span class="op">=</span> <span class="cn">TRUE</span></span>
<span><span class="op">)</span></span></code></pre></div>
    </div>

    <div class="section level2">
    <h2 id="arguments">Arguments<a class="anchor" aria-label="anchor" href="#arguments"></a></h2>
    <dl><dt>mapping</dt>
<dd><p>Set of aesthetic mappings created by <code><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes()</a></code>. If specified and
<code>inherit.aes = TRUE</code> (the default), it is combined with the default mapping
at the top level of the plot. You must supply <code>mapping</code> if there is no plot
mapping.</p></dd>


<dt>data</dt>
<dd><p>The data to be displayed in this layer. There are three
options:</p>
<p>If <code>NULL</code>, the default, the data is inherited from the plot
data as specified in the call to <code><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot()</a></code>.</p>
<p>A <code>data.frame</code>, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
<code><a href="https://ggplot2.tidyverse.org/reference/fortify.html" class="external-link">fortify()</a></code> for which variables will be created.</p>
<p>A <code>function</code> will be called with a single argument,
the plot data. The return value must be a <code>data.frame</code>, and
will be used as the layer data. A <code>function</code> can be created
from a <code>formula</code> (e.g. <code>~ head(.x, 10)</code>).</p></dd>


<dt>geom</dt>
<dd><p>Use to override the default connection between
<code>stat_slabinterval()</code> and <code><a href="geom_slabinterval.html">geom_slabinterval()</a></code></p></dd>


<dt>position</dt>
<dd><p>Position adjustment, either as a string, or the result of a call to a position adjustment function.
Setting this equal to <code>"dodge"</code> (<code><a href="https://ggplot2.tidyverse.org/reference/position_dodge.html" class="external-link">position_dodge()</a></code>) or <code>"dodgejust"</code> (<code><a href="position_dodgejust.html">position_dodgejust()</a></code>) can be useful if
you have overlapping geometries.</p></dd>


<dt>...</dt>
<dd><p>Other arguments passed to <code><a href="https://ggplot2.tidyverse.org/reference/layer.html" class="external-link">layer()</a></code>. These are often aesthetics, used to set an aesthetic
to a fixed value, like <code>colour = "red"</code> or <code>linewidth = 3</code> (see <strong>Aesthetics</strong>, below). They may also be
parameters to the paired geom/stat. When paired with the default geom, <code><a href="geom_slabinterval.html">geom_slabinterval()</a></code>,
these include:</p><dl><dt><code>normalize</code></dt>
<dd><p>How to normalize heights of functions input to the <code>thickness</code> aesthetic. One of:</p><ul><li><p><code>"all"</code>: normalize so that the maximum height across all data is <code>1</code>.</p></li>
<li><p><code>"panels"</code>: normalize within panels so that the maximum height in each panel is <code>1</code>.</p></li>
<li><p><code>"xy"</code>: normalize within the x/y axis opposite the <code>orientation</code> of this geom so
that the maximum height at each value of the opposite axis is <code>1</code>.</p></li>
<li><p><code>"groups"</code>: normalize within values of the opposite axis and within each
group so that the maximum height in each group is <code>1</code>.</p></li>
<li><p><code>"none"</code>: values are taken as is with no normalization (this should probably
only be used with functions whose values are in [0,1], such as CDFs).</p></li>
</ul><p>For a comprehensive discussion and examples of slab scaling and normalization, see the
<a href="https://mjskay.github.io/ggdist/articles/thickness.html" class="external-link"><code>thickness</code> scale article</a>.</p></dd>

<dt><code>fill_type</code></dt>
<dd><p>What type of fill to use when the fill color or alpha varies within a slab. One of:</p><ul><li><p><code>"segments"</code>: breaks up the slab geometry into segments for each unique combination of fill color and
alpha value. This approach is supported by all graphics devices and works well for sharp cutoff values,
but can give ugly results if a large number of unique fill colors are being used (as in gradients,
like in <code><a href="stat_gradientinterval.html">stat_gradientinterval()</a></code>).</p></li>
<li><p><code>"gradient"</code>: a <code><a href="https://rdrr.io/r/grid/patterns.html" class="external-link">grid::linearGradient()</a></code> is used to create a smooth gradient fill. This works well for
large numbers of unique fill colors, but requires R &gt;= 4.1 and is not yet supported on all graphics devices.
As of this writing, the <code><a href="https://rdrr.io/r/grDevices/png.html" class="external-link">png()</a></code> graphics device with <code>type = "cairo"</code>, the <code><a href="https://rdrr.io/r/grDevices/cairo.html" class="external-link">svg()</a></code> device, the <code><a href="https://rdrr.io/r/grDevices/pdf.html" class="external-link">pdf()</a></code>
device, and the <code><a href="https://ragg.r-lib.org/reference/agg_png.html" class="external-link">ragg::agg_png()</a></code> devices are known to support this option. On R &lt; 4.1, this option
will fall back to <code>fill_type = "segments"</code> with a message.</p></li>
<li><p><code>"auto"</code>: attempts to use <code>fill_type = "gradient"</code> if support for it can be auto-detected. On R &gt;= 4.2,
support for gradients can be auto-detected on some graphics devices; if support is not detected, this
option will fall back to <code>fill_type = "segments"</code> (in case of a false negative, <code>fill_type = "gradient"</code>
can be set explicitly). On R &lt; 4.2, support for gradients cannot be auto-detected, so this will always
fall back to <code>fill_type = "segments"</code>, in which case you can set <code>fill_type = "gradient"</code> explicitly
if you are using a graphics device that support gradients.</p></li>
</ul></dd>

<dt><code>interval_size_domain</code></dt>
<dd><p>A length-2 numeric vector giving the minimum and maximum of the values of the <code>size</code> and <code>linewidth</code> aesthetics
that will be translated into actual sizes for intervals drawn according to <code>interval_size_range</code> (see the
documentation for that argument.)</p></dd>

<dt><code>interval_size_range</code></dt>
<dd><p>A length-2 numeric vector. This geom scales the raw size aesthetic values when drawing interval and point
sizes, as they tend to be too thick when using the default settings of <code><a href="https://ggplot2.tidyverse.org/reference/scale_size.html" class="external-link">scale_size_continuous()</a></code>, which give
sizes with a range of <code>c(1, 6)</code>. The <code>interval_size_domain</code> value indicates the input domain of raw size
values (typically this should be equal to the value of the <code>range</code> argument of the <code><a href="https://ggplot2.tidyverse.org/reference/scale_size.html" class="external-link">scale_size_continuous()</a></code>
function), and <code>interval_size_range</code> indicates the desired output range of the size values (the min and max of
the actual sizes used to draw intervals). Most of the time it is not recommended to change the value of this
argument, as it may result in strange scaling of legends; this argument is a holdover from earlier versions
that did not have size aesthetics targeting the point and interval separately. If you want to adjust the
size of the interval or points separately, you can also use the <code>linewidth</code> or <code>point_size</code>
aesthetics; see <a href="sub-geometry-scales.html">sub-geometry-scales</a>.</p></dd>

<dt><code>fatten_point</code></dt>
<dd><p>A multiplicative factor used to adjust the size of the point relative to the size of the
thickest interval line. If you wish to specify point sizes directly, you can also use the <code>point_size</code>
aesthetic and <code><a href="sub-geometry-scales.html">scale_point_size_continuous()</a></code> or <code><a href="sub-geometry-scales.html">scale_point_size_discrete()</a></code>; sizes
specified with that aesthetic will not be adjusted using <code>fatten_point</code>.</p></dd>

<dt><code>arrow</code></dt>
<dd><p><code><a href="https://rdrr.io/r/grid/arrow.html" class="external-link">grid::arrow()</a></code> giving the arrow heads to use on the interval, or <code>NULL</code> for no arrows.</p></dd>

<dt><code>subguide</code></dt>
<dd><p>Sub-guide used to annotate the <code>thickness</code> scale. One of:</p><ul><li><p>A function that takes a <code>scale</code> argument giving a <a href="https://ggplot2.tidyverse.org/reference/ggplot2-ggproto.html" class="external-link">ggplot2::Scale</a>
object and an <code>orientation</code> argument giving the orientation of the
geometry and then returns a <a href="https://rdrr.io/r/grid/grid-defunct.html" class="external-link">grid::grob</a> that will draw the axis
annotation, such as <code><a href="subguide_axis.html">subguide_axis()</a></code> (to draw a traditional axis) or
<code><a href="subguide_none.html">subguide_none()</a></code> (to draw no annotation). See <code><a href="subguide_axis.html">subguide_axis()</a></code>
for a list of possibilities and examples.</p></li>
<li><p>A string giving the name of such a function when prefixed
with <code>"subguide"</code>; e.g. <code>"axis"</code> or <code>"none"</code>.</p></li>
</ul></dd>


</dl></dd>


<dt>p_limits</dt>
<dd><p>Probability limits (as a vector of size 2) used to determine the lower and upper
limits of <em>theoretical</em> distributions (distributions from <em>samples</em> ignore this parameter and determine
their limits based on the limits of the sample). E.g., if this is <code>c(.001, .999)</code>, then a slab is drawn
for the distribution from the quantile at <code>p = .001</code> to the quantile at <code>p = .999</code>. If the lower
(respectively upper) limit is <code>NA</code>, then the lower (upper) limit will be the minimum (maximum) of the
distribution's support if it is finite, and <code>0.001</code> (<code>0.999</code>) if it is not finite. E.g., if
<code>p_limits</code> is <code>c(NA, NA)</code>, on a gamma distribution the effective value of <code>p_limits</code> would be
<code>c(0, .999)</code> since the gamma distribution is defined on <code>(0, Inf)</code>; whereas on a normal distribution
it would be equivalent to <code>c(.001, .999)</code> since the normal distribution is defined on <code>(-Inf, Inf)</code>.</p></dd>


<dt>density</dt>
<dd><p>Density estimator for sample data. One of:</p><ul><li><p>A function which takes a numeric vector and returns a list with elements
<code>x</code> (giving grid points for the density estimator) and <code>y</code> (the
corresponding densities). <span class="pkg">ggdist</span> provides a family of functions
following this format, including <code><a href="density_unbounded.html">density_unbounded()</a></code> and
<code><a href="density_bounded.html">density_bounded()</a></code>. This format is also compatible with <code><a href="https://rdrr.io/r/stats/density.html" class="external-link">stats::density()</a></code>.</p></li>
<li><p>A string giving the suffix of a function name that starts with <code>"density_"</code>;
e.g. <code>"bounded"</code> for <code>[density_bounded()]</code>, <code>"unbounded"</code> for <code>[density_unbounded()]</code>,
or <code>"histogram"</code> for <code><a href="density_histogram.html">density_histogram()</a></code>.
Defaults to <code>"bounded"</code>, i.e. <code><a href="density_bounded.html">density_bounded()</a></code>, which estimates the bounds from
the data and then uses a bounded density estimator based on the reflection method.</p></li>
</ul></dd>


<dt>adjust</dt>
<dd><p>Passed to <code>density</code>: the bandwidth for the density estimator for sample data
is adjusted by multiplying it by this value. See e.g. <code><a href="density_bounded.html">density_bounded()</a></code> for more information.
Default (<code><a href="https://ggplot2.tidyverse.org/reference/waiver.html" class="external-link">waiver()</a></code>) defers to the default of the density estimator, which is usually <code>1</code>.</p></dd>


<dt>trim</dt>
<dd><p>For sample data, should the density estimate be trimmed to the range of the
data? Passed on to the density estimator; see the <code>density</code> parameter. Default <code>TRUE</code>.</p></dd>


<dt>expand</dt>
<dd><p>For sample data, should the slab be expanded to the limits of the scale? Default <code>FALSE</code>.
Can be length two to control expansion to the lower and upper limit respectively.</p></dd>


<dt>breaks</dt>
<dd><p>Determines the breakpoints defining bins. Defaults to <code>"Scott"</code>.
Similar to (but not exactly the same as) the <code>breaks</code> argument to <code><a href="https://rdrr.io/r/graphics/hist.html" class="external-link">graphics::hist()</a></code>.
One of:</p><ul><li><p>A scalar (length-1) numeric giving the number of bins</p></li>
<li><p>A vector numeric giving the breakpoints between histogram bins</p></li>
<li><p>A function taking <code>x</code> and <code>weights</code> and returning either the
number of bins or a vector of breakpoints</p></li>
<li><p>A string giving the suffix of a function that starts with
<code>"breaks_"</code>. <span class="pkg">ggdist</span> provides weighted implementations of the
<code>"Sturges"</code>, <code>"Scott"</code>, and <code>"FD"</code> break-finding algorithms from
<code><a href="https://rdrr.io/r/graphics/hist.html" class="external-link">graphics::hist()</a></code>, as well as <code><a href="breaks.html">breaks_fixed()</a></code> for manually setting
the bin width. See <a href="breaks.html">breaks</a>.</p></li>
</ul><p>For example, <code>breaks = "Sturges"</code> will use the <code><a href="breaks.html">breaks_Sturges()</a></code> algorithm,
<code>breaks = 9</code> will create 9 bins, and <code>breaks = breaks_fixed(width = 1)</code> will
set the bin width to <code>1</code>.</p></dd>


<dt>align</dt>
<dd><p>Determines how to align the breakpoints defining bins. Default
(<code>"none"</code>) performs no alignment. One of:</p><ul><li><p>A scalar (length-1) numeric giving an offset that is subtracted from the breaks.
The offset must be between <code>0</code> and the bin width.</p></li>
<li><p>A function taking a sorted vector of <code>breaks</code> (bin edges) and returning
an offset to subtract from the breaks.</p></li>
<li><p>A string giving the suffix of a function that starts with
<code>"align_"</code> used to determine the alignment, such as <code><a href="align.html">align_none()</a></code>,
<code><a href="align.html">align_boundary()</a></code>, or <code><a href="align.html">align_center()</a></code>.</p></li>
</ul><p>For example, <code>align = "none"</code> will provide no alignment, <code>align = align_center(at = 0)</code>
will center a bin on <code>0</code>, and <code>align = align_boundary(at = 0)</code> will align a bin
edge on <code>0</code>.</p></dd>


<dt>outline_bars</dt>
<dd><p>For sample data (if <code>density</code> is <code>"histogram"</code>) and for discrete analytical
distributions (whose slabs are drawn as histograms), determines
if outlines in between the bars are drawn when the <code>slab_color</code> aesthetic is used. If <code>FALSE</code>
(the default), the outline is drawn only along the tops of the bars; if <code>TRUE</code>, outlines in between
bars are also drawn. See <code><a href="density_histogram.html">density_histogram()</a></code>.</p></dd>


<dt>point_interval</dt>
<dd><p>A function from the <code><a href="point_interval.html">point_interval()</a></code> family (e.g., <code>median_qi</code>,
<code>mean_qi</code>, <code>mode_hdi</code>, etc), or a string giving the name of a function from that family
(e.g., <code>"median_qi"</code>, <code>"mean_qi"</code>, <code>"mode_hdi"</code>, etc; if a string, the caller's environment is searched
for the function, followed by the <span class="pkg">ggdist</span> environment). This function determines the point summary
(typically mean, median, or mode) and interval type (quantile interval, <code>qi</code>;
highest-density interval, <code>hdi</code>; or highest-density continuous interval, <code>hdci</code>). Output will
be converted to the appropriate <code>x</code>- or <code>y</code>-based aesthetics depending on the value of <code>orientation</code>.
See the <code><a href="point_interval.html">point_interval()</a></code> family of functions for more information.</p></dd>


<dt>slab_type</dt>
<dd><p>(deprecated) The type of slab function to calculate: probability density (or mass) function
(<code>"pdf"</code>), cumulative distribution function (<code>"cdf"</code>), or complementary CDF (<code>"ccdf"</code>). Instead of using
<code>slab_type</code> to change <code>f</code> and then mapping <code>f</code> onto an aesthetic, it is now recommended to simply map the
corresponding computed variable (e.g. <code>pdf</code>, <code>cdf</code>, or  <code>1 - cdf</code>) directly onto the desired aesthetic.</p></dd>


<dt>limits</dt>
<dd><p>Manually-specified limits for the slab, as a vector of length two. These limits are combined with those
computed based on <code>p_limits</code> as well as the limits defined by the scales of the plot to determine the
limits used to draw the slab functions: these limits specify the maximal limits; i.e., if specified, the limits
will not be wider than these (but may be narrower). Use <code>NA</code> to leave a limit alone; e.g.
<code>limits = c(0, NA)</code> will ensure that the lower limit does not go below 0, but let the upper limit
be determined by either <code>p_limits</code> or the scale settings.</p></dd>


<dt>n</dt>
<dd><p>Number of points at which to evaluate the function that defines the slab.</p></dd>


<dt>.width</dt>
<dd><p>The <code>.width</code> argument passed to <code>point_interval</code>: a vector of probabilities to use
that determine the widths of the resulting intervals. If multiple probabilities are provided,
multiple intervals per group are generated, each with a different probability interval (and
value of the corresponding <code>.width</code> and <code>level</code> generated variables).</p></dd>


<dt>orientation</dt>
<dd><p>Whether this geom is drawn horizontally or vertically. One of:</p><ul><li><p><code>NA</code> (default): automatically detect the orientation based on how the aesthetics
are assigned. Automatic detection works most of the time.</p></li>
<li><p><code>"horizontal"</code> (or <code>"y"</code>): draw horizontally, using the <code>y</code> aesthetic to identify different
groups. For each group, uses the <code>x</code>, <code>xmin</code>, <code>xmax</code>, and <code>thickness</code> aesthetics to
draw points, intervals, and slabs.</p></li>
<li><p><code>"vertical"</code> (or <code>"x"</code>): draw vertically, using the <code>x</code> aesthetic to identify different
groups. For each group, uses the <code>y</code>, <code>ymin</code>, <code>ymax</code>, and <code>thickness</code> aesthetics to
draw points, intervals, and slabs.</p></li>
</ul><p>For compatibility with the base ggplot naming scheme for <code>orientation</code>, <code>"x"</code> can be used as an alias
for <code>"vertical"</code> and <code>"y"</code> as an alias for <code>"horizontal"</code> (<span class="pkg">ggdist</span> had an <code>orientation</code> parameter
before base ggplot did, hence the discrepancy).</p></dd>


<dt>na.rm</dt>
<dd><p>If <code>FALSE</code>, the default, missing values are removed with a warning. If <code>TRUE</code>, missing
values are silently removed.</p></dd>


<dt>show.legend</dt>
<dd><p>Should this layer be included in the legends? Default is <code>c(size = FALSE)</code>, unlike most geoms,
to match its common use cases. <code>FALSE</code> hides all legends, <code>TRUE</code> shows all legends, and <code>NA</code> shows only
those that are mapped (the default for most geoms).</p></dd>


<dt>inherit.aes</dt>
<dd><p>If <code>FALSE</code>, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. <code><a href="https://ggplot2.tidyverse.org/reference/borders.html" class="external-link">borders()</a></code>.</p></dd>

</dl></div>
    <div class="section level2">
    <h2 id="value">Value<a class="anchor" aria-label="anchor" href="#value"></a></h2>
    

<p>A <a href="https://ggplot2.tidyverse.org/reference/ggplot2-ggproto.html" class="external-link">ggplot2::Stat</a> representing a slab or combined slab+interval geometry which can
be added to a <code><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot()</a></code> object.</p>
    </div>
    <div class="section level2">
    <h2 id="details">Details<a class="anchor" aria-label="anchor" href="#details"></a></h2>
    <p>A highly configurable stat for generating a variety of plots that combine a "slab"
that describes a distribution plus a point summary and any number of intervals.
Several "shortcut" stats are provided
which combine multiple options to create useful geoms, particularly <em>eye plots</em>
(a violin plot of density plus interval), <em>half-eye plots</em> (a density plot plus interval),
<em>CCDF bar plots</em> (a complementary CDF plus interval), and <em>gradient plots</em>
(a density encoded in color alpha plus interval).</p>
<p>The shortcut stats include:</p><ul><li><p><code><a href="stat_eye.html">stat_eye()</a></code>: Eye plots (violin + interval)</p></li>
<li><p><code><a href="stat_halfeye.html">stat_halfeye()</a></code>: Half-eye plots (density + interval)</p></li>
<li><p><code><a href="stat_ccdfinterval.html">stat_ccdfinterval()</a></code>: CCDF bar plots (CCDF + interval)</p></li>
<li><p><code><a href="stat_cdfinterval.html">stat_cdfinterval()</a></code>: CDF bar plots (CDF + interval)</p></li>
<li><p><code><a href="stat_gradientinterval.html">stat_gradientinterval()</a></code>: Density gradient + interval plots</p></li>
<li><p><code><a href="stat_slab.html">stat_slab()</a></code>: Density plots</p></li>
<li><p><code><a href="stat_histinterval.html">stat_histinterval()</a></code>: Histogram + interval plots</p></li>
<li><p><code><a href="stat_pointinterval.html">stat_pointinterval()</a></code>: Point + interval plots</p></li>
<li><p><code><a href="stat_interval.html">stat_interval()</a></code>: Interval plots</p></li>
</ul><p><strong>To visualize sample data</strong>, such as a data distribution, samples from a
bootstrap distribution, or a Bayesian posterior, you can supply samples to
the <code>x</code> or <code>y</code> aesthetic.</p>
<p><strong>To visualize analytical distributions</strong>, you can use the <code>xdist</code> or <code>ydist</code>
aesthetic. For historical reasons, you can also use <code>dist</code> to specify the distribution, though
this is not recommended as it does not work as well with orientation detection.
These aesthetics can be used as follows:</p><ul><li><p><code>xdist</code>, <code>ydist</code>, and <code>dist</code> can be any distribution object from the <a href="https://pkg.mitchelloharawild.com/distributional/" class="external-link">distributional</a>
package (<code><a href="https://pkg.mitchelloharawild.com/distributional/reference/dist_normal.html" class="external-link">dist_normal()</a></code>, <code><a href="https://pkg.mitchelloharawild.com/distributional/reference/dist_beta.html" class="external-link">dist_beta()</a></code>, etc) or can be a <code><a href="https://mc-stan.org/posterior/reference/rvar.html" class="external-link">posterior::rvar()</a></code> object.
Since these functions are vectorized,
other columns can be passed directly to them in an <code><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes()</a></code> specification; e.g.
<code>aes(dist = dist_normal(mu, sigma))</code> will work if <code>mu</code> and <code>sigma</code> are columns in the
input data frame.</p></li>
<li><p><code>dist</code> can be a character vector giving the distribution name. Then the  <code>arg1</code>, ... <code>arg9</code>
aesthetics (or <code>args</code> as a list column) specify distribution arguments. Distribution names
should correspond to R functions that have <code>"p"</code>, <code>"q"</code>, and <code>"d"</code> functions; e.g. <code>"norm"</code>
is a valid distribution name because R defines the <code><a href="https://rdrr.io/r/stats/Normal.html" class="external-link">pnorm()</a></code>, <code><a href="https://rdrr.io/r/stats/Normal.html" class="external-link">qnorm()</a></code>, and <code><a href="https://rdrr.io/r/stats/Normal.html" class="external-link">dnorm()</a></code>
functions for Normal distributions.</p>
<p>See the <code><a href="parse_dist.html">parse_dist()</a></code> function for a useful way to generate <code>dist</code> and <code>args</code>
values from human-readable distribution specs (like <code>"normal(0,1)"</code>). Such specs are also
produced by other packages (like the <code><a href="https://paul-buerkner.github.io/brms/reference/get_prior.html" class="external-link">brms::get_prior</a></code> function in brms); thus,
<code><a href="parse_dist.html">parse_dist()</a></code> combined with the stats described here can help you visualize the output
of those functions.</p></li>
</ul></div>
    <div class="section level2">
    <h2 id="computed-variables">Computed Variables<a class="anchor" aria-label="anchor" href="#computed-variables"></a></h2>
    

<p>The following variables are computed by this stat and made available for
use in aesthetic specifications (<code><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes()</a></code>) using the <code><a href="https://ggplot2.tidyverse.org/reference/aes_eval.html" class="external-link">after_stat()</a></code>
function or the <code>after_stat</code> argument of <code><a href="https://ggplot2.tidyverse.org/reference/aes_eval.html" class="external-link">stage()</a></code>:</p><ul><li><p><code>x</code> or <code>y</code>: For slabs, the input values to the slab function.
For intervals, the point summary from the interval function. Whether it is <code>x</code> or <code>y</code> depends on <code>orientation</code></p></li>
<li><p><code>xmin</code> or <code>ymin</code>: For intervals, the lower end of the interval from the interval function.</p></li>
<li><p><code>xmax</code> or <code>ymax</code>: For intervals, the upper end of the interval from the interval function.</p></li>
<li><p><code>.width</code>: For intervals, the interval width as a numeric value in <code>[0, 1]</code>.
For slabs, the width of the smallest interval containing that value of the slab.</p></li>
<li><p><code>level</code>: For intervals, the interval width as an ordered factor.
For slabs, the level of the smallest interval containing that value of the slab.</p></li>
<li><p><code>pdf</code>: For slabs, the probability density function (PDF).
If <code>options("ggdist.experimental.slab_data_in_intervals")</code> is <code>TRUE</code>:
For intervals, the PDF at the point summary; intervals also have <code>pdf_min</code> and <code>pdf_max</code>
for the PDF at the lower and upper ends of the interval.</p></li>
<li><p><code>cdf</code>: For slabs, the cumulative distribution function.
If <code>options("ggdist.experimental.slab_data_in_intervals")</code> is <code>TRUE</code>:
For intervals, the CDF at the point summary; intervals also have <code>cdf_min</code> and <code>cdf_max</code>
for the CDF at the lower and upper ends of the interval.</p></li>
<li><p><code>n</code>: For slabs, the number of data points summarized into that slab. If the slab was created from
an analytical distribution via the <code>xdist</code>, <code>ydist</code>, or <code>dist</code> aesthetic, <code>n</code> will be <code>Inf</code>.</p></li>
<li><p><code>f</code>: (deprecated) For slabs, the output values from the slab function (such as the PDF, CDF, or CCDF),
determined by <code>slab_type</code>. Instead of using <code>slab_type</code> to change <code>f</code> and then mapping <code>f</code> onto an
aesthetic, it is now recommended to simply map the corresponding computed variable (e.g. <code>pdf</code>, <code>cdf</code>, or
<code>1 - cdf</code>) directly onto the desired aesthetic.</p></li>
</ul></div>
    <div class="section level2">
    <h2 id="aesthetics">Aesthetics<a class="anchor" aria-label="anchor" href="#aesthetics"></a></h2>
    

<p>The slab+interval <code>stat</code>s and <code>geom</code>s have a wide variety of aesthetics that control
the appearance of their three sub-geometries: the <strong>slab</strong>, the <strong>point</strong>, and
the <strong>interval</strong>.</p>
<p>These <code>stat</code>s support the following aesthetics:</p>
<ul><li><p><code>x</code>: x position of the geometry (when orientation = <code>"vertical"</code>); or sample data to be summarized
(when <code>orientation = "horizontal"</code> with sample data).</p></li>
<li><p><code>y</code>: y position of the geometry (when orientation = <code>"horizontal"</code>); or sample data to be summarized
(when <code>orientation = "vertical"</code> with sample data).</p></li>
<li><p><code>weight</code>: When using samples (i.e. the <code>x</code> and <code>y</code> aesthetics, not <code>xdist</code> or <code>ydist</code>), optional
weights to be applied to each draw.</p></li>
<li><p><code>xdist</code>: When using analytical distributions, distribution to map on the x axis: a <span class="pkg">distributional</span>
object (e.g. <code><a href="https://pkg.mitchelloharawild.com/distributional/reference/dist_normal.html" class="external-link">dist_normal()</a></code>) or a <code><a href="https://mc-stan.org/posterior/reference/rvar.html" class="external-link">posterior::rvar()</a></code> object.</p></li>
<li><p><code>ydist</code>: When using analytical distributions, distribution to map on the y axis: a <span class="pkg">distributional</span>
object (e.g. <code><a href="https://pkg.mitchelloharawild.com/distributional/reference/dist_normal.html" class="external-link">dist_normal()</a></code>) or a <code><a href="https://mc-stan.org/posterior/reference/rvar.html" class="external-link">posterior::rvar()</a></code> object.</p></li>
<li><p><code>dist</code>: When using analytical distributions, a name of a distribution (e.g. <code>"norm"</code>), a
<span class="pkg">distributional</span> object (e.g. <code><a href="https://pkg.mitchelloharawild.com/distributional/reference/dist_normal.html" class="external-link">dist_normal()</a></code>), or a <code><a href="https://mc-stan.org/posterior/reference/rvar.html" class="external-link">posterior::rvar()</a></code> object. See <strong>Details</strong>.</p></li>
<li><p><code>args</code>: Distribution arguments (<code>args</code> or <code>arg1</code>, ... <code>arg9</code>). See <strong>Details</strong>.</p></li>
</ul><p>In addition, in their default configuration (paired with <code><a href="geom_slabinterval.html">geom_slabinterval()</a></code>)
the following aesthetics are supported by the underlying geom:</p>
<p><strong>Slab-specific aesthetics</strong></p>
<ul><li><p><code>thickness</code>: The thickness of the slab at each <code>x</code> value (if <code>orientation = "horizontal"</code>) or
<code>y</code> value (if <code>orientation = "vertical"</code>) of the slab.</p></li>
<li><p><code>side</code>: Which side to place the slab on. <code>"topright"</code>, <code>"top"</code>, and <code>"right"</code> are synonyms
which cause the slab to be drawn on the top or the right depending on if <code>orientation</code> is <code>"horizontal"</code>
or <code>"vertical"</code>. <code>"bottomleft"</code>, <code>"bottom"</code>, and <code>"left"</code> are synonyms which cause the slab
to be drawn on the bottom or the left depending on if <code>orientation</code> is <code>"horizontal"</code> or
<code>"vertical"</code>. <code>"topleft"</code> causes the slab to be drawn on the top or the left, and <code>"bottomright"</code>
causes the slab to be drawn on the bottom or the right. <code>"both"</code> draws the slab mirrored on both
sides (as in a violin plot).</p></li>
<li><p><code>scale</code>: What proportion of the region allocated to this geom to use to draw the slab. If <code>scale = 1</code>,
slabs that use the maximum range will just touch each other. Default is <code>0.9</code> to leave some space
between adjacent slabs. For a comprehensive discussion and examples of slab scaling and normalization,
see the <a href="https://mjskay.github.io/ggdist/articles/thickness.html" class="external-link"><code>thickness</code> scale article</a>.</p></li>
<li><p><code>justification</code>: Justification of the interval relative to the slab, where <code>0</code> indicates bottom/left
justification and <code>1</code> indicates top/right justification (depending on <code>orientation</code>). If <code>justification</code>
is <code>NULL</code> (the default), then it is set automatically based on the value of <code>side</code>: when <code>side</code> is
<code>"top"</code>/<code>"right"</code> <code>justification</code> is set to <code>0</code>, when <code>side</code> is <code>"bottom"</code>/<code>"left"</code>
<code>justification</code> is set to <code>1</code>, and when <code>side</code> is <code>"both"</code> <code>justification</code> is set to 0.5.</p></li>
<li><p><code>datatype</code>: When using composite geoms directly without a <code>stat</code> (e.g. <code><a href="geom_slabinterval.html">geom_slabinterval()</a></code>), <code>datatype</code> is used to
indicate which part of the geom a row in the data targets: rows with <code>datatype = "slab"</code> target the
slab portion of the geometry and rows with <code>datatype = "interval"</code> target the interval portion of
the geometry. This is set automatically when using ggdist <code>stat</code>s.</p></li>
</ul><p><strong>Interval-specific aesthetics</strong></p>
<ul><li><p><code>xmin</code>: Left end of the interval sub-geometry (if <code>orientation = "horizontal"</code>).</p></li>
<li><p><code>xmax</code>: Right end of the interval sub-geometry (if <code>orientation = "horizontal"</code>).</p></li>
<li><p><code>ymin</code>: Lower end of the interval sub-geometry (if <code>orientation = "vertical"</code>).</p></li>
<li><p><code>ymax</code>: Upper end of the interval sub-geometry (if <code>orientation = "vertical"</code>).</p></li>
</ul><p><strong>Point-specific aesthetics</strong></p>
<ul><li><p><code>shape</code>: Shape type used to draw the <strong>point</strong> sub-geometry.</p></li>
</ul><p><strong>Color aesthetics</strong></p>
<ul><li><p><code>colour</code>: (or <code>color</code>) The color of the <strong>interval</strong> and <strong>point</strong> sub-geometries.
Use the <code>slab_color</code>, <code>interval_color</code>, or <code>point_color</code> aesthetics (below) to
set sub-geometry colors separately.</p></li>
<li><p><code>fill</code>: The fill color of the <strong>slab</strong> and <strong>point</strong> sub-geometries. Use the <code>slab_fill</code>
or <code>point_fill</code> aesthetics (below) to set sub-geometry colors separately.</p></li>
<li><p><code>alpha</code>: The opacity of the <strong>slab</strong>, <strong>interval</strong>, and <strong>point</strong> sub-geometries. Use the <code>slab_alpha</code>,
<code>interval_alpha</code>, or <code>point_alpha</code> aesthetics (below) to set sub-geometry colors separately.</p></li>
<li><p><code>colour_ramp</code>: (or <code>color_ramp</code>) A secondary scale that modifies the <code>color</code>
scale to "ramp" to another color. See <code><a href="scale_colour_ramp.html">scale_colour_ramp()</a></code> for examples.</p></li>
<li><p><code>fill_ramp</code>: A secondary scale that modifies the <code>fill</code>
scale to "ramp" to another color. See <code><a href="scale_colour_ramp.html">scale_fill_ramp()</a></code> for examples.</p></li>
</ul><p><strong>Line aesthetics</strong></p>
<ul><li><p><code>linewidth</code>: Width of the line used to draw the <strong>interval</strong> (except with <code><a href="geom_slab.html">geom_slab()</a></code>: then
it is the width of the <strong>slab</strong>). With composite geometries including an interval and slab,
use <code>slab_linewidth</code> to set the line width of the <strong>slab</strong> (see below). For <strong>interval</strong>, raw
<code>linewidth</code> values are transformed according to the <code>interval_size_domain</code> and <code>interval_size_range</code>
parameters of the <code>geom</code> (see above).</p></li>
<li><p><code>size</code>: Determines the size of the <strong>point</strong>. If <code>linewidth</code> is not provided, <code>size</code> will
also determines the width of the line used to draw the <strong>interval</strong> (this allows line width and
point size to be modified together by setting only <code>size</code> and not <code>linewidth</code>). Raw
<code>size</code> values are transformed according to the <code>interval_size_domain</code>, <code>interval_size_range</code>,
and <code>fatten_point</code> parameters of the <code>geom</code> (see above). Use the <code>point_size</code> aesthetic
(below) to set sub-geometry size directly without applying the effects of
<code>interval_size_domain</code>, <code>interval_size_range</code>, and <code>fatten_point</code>.</p></li>
<li><p><code>stroke</code>: Width of the outline around the <strong>point</strong> sub-geometry.</p></li>
<li><p><code>linetype</code>: Type of line (e.g., <code>"solid"</code>, <code>"dashed"</code>, etc) used to draw the <strong>interval</strong>
and the outline of the <strong>slab</strong> (if it is visible). Use the <code>slab_linetype</code> or
<code>interval_linetype</code> aesthetics (below) to set sub-geometry line types separately.</p></li>
</ul><p><strong>Slab-specific color and line override aesthetics</strong></p>
<ul><li><p><code>slab_fill</code>: Override for <code>fill</code>: the fill color of the slab.</p></li>
<li><p><code>slab_colour</code>: (or <code>slab_color</code>) Override for <code>colour</code>/<code>color</code>: the outline color of the slab.</p></li>
<li><p><code>slab_alpha</code>: Override for <code>alpha</code>: the opacity of the slab.</p></li>
<li><p><code>slab_linewidth</code>: Override for <code>linwidth</code>: the width of the outline of the slab.</p></li>
<li><p><code>slab_linetype</code>: Override for <code>linetype</code>: the line type of the outline of the slab.</p></li>
</ul><p><strong>Interval-specific color and line override aesthetics</strong></p>
<ul><li><p><code>interval_colour</code>: (or <code>interval_color</code>) Override for <code>colour</code>/<code>color</code>: the color of the interval.</p></li>
<li><p><code>interval_alpha</code>: Override for <code>alpha</code>: the opacity of the interval.</p></li>
<li><p><code>interval_linetype</code>: Override for <code>linetype</code>: the line type of the interval.</p></li>
</ul><p><strong>Point-specific color and line override aesthetics</strong></p>
<ul><li><p><code>point_fill</code>: Override for <code>fill</code>: the fill color of the point.</p></li>
<li><p><code>point_colour</code>: (or <code>point_color</code>) Override for <code>colour</code>/<code>color</code>: the outline color of the point.</p></li>
<li><p><code>point_alpha</code>: Override for <code>alpha</code>: the opacity of the point.</p></li>
<li><p><code>point_size</code>: Override for <code>size</code>: the size of the point.</p></li>
</ul><p><strong>Deprecated aesthetics</strong></p>
<ul><li><p><code>slab_size</code>: Use <code>slab_linewidth</code>.</p></li>
<li><p><code>interval_size</code>: Use <code>interval_linewidth</code>.</p></li>
</ul><p><strong>Other aesthetics</strong> (these work as in standard <code>geom</code>s)</p>
<ul><li><p><code>width</code></p></li>
<li><p><code>height</code></p></li>
<li><p><code>group</code></p></li>
</ul><p>See examples of some of these aesthetics in action in <code><a href="../articles/slabinterval.html">vignette("slabinterval")</a></code>.
Learn more about the sub-geom override aesthetics (like <code>interval_color</code>) in the
<a href="sub-geometry-scales.html">scales</a> documentation. Learn more about basic ggplot aesthetics in
<code><a href="https://ggplot2.tidyverse.org/articles/ggplot2-specs.html" class="external-link">vignette("ggplot2-specs")</a></code>.</p>
    </div>
    <div class="section level2">
    <h2 id="see-also">See also<a class="anchor" aria-label="anchor" href="#see-also"></a></h2>
    <div class="dont-index"><p>See <code><a href="geom_slabinterval.html">geom_slabinterval()</a></code> for more information on the geom these stats
use by default and some of the options it has.
See <code><a href="../articles/slabinterval.html">vignette("slabinterval")</a></code> for a variety of examples of use.</p></div>
    </div>

    <div class="section level2">
    <h2 id="ref-examples">Examples<a class="anchor" aria-label="anchor" href="#ref-examples"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span class="r-in"><span></span></span>
<span class="r-in"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org" class="external-link">dplyr</a></span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://ggplot2.tidyverse.org" class="external-link">ggplot2</a></span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://pkg.mitchelloharawild.com/distributional/" class="external-link">distributional</a></span><span class="op">)</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/theme_get.html" class="external-link">theme_set</a></span><span class="op">(</span><span class="fu"><a href="theme_ggdist.html">theme_ggdist</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># EXAMPLES ON SAMPLE DATA</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/base/Random.html" class="external-link">set.seed</a></span><span class="op">(</span><span class="fl">1234</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">df</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span></span></span>
<span class="r-in"><span>  group <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"a"</span>, <span class="st">"b"</span>, <span class="st">"c"</span>, <span class="st">"c"</span>, <span class="st">"c"</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>  value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html" class="external-link">rnorm</a></span><span class="op">(</span><span class="fl">2500</span>, mean <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">5</span>, <span class="fl">7</span>, <span class="fl">9</span>, <span class="fl">9</span>, <span class="fl">9</span><span class="op">)</span>, sd <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">1</span>, <span class="fl">1.5</span>, <span class="fl">1</span>, <span class="fl">1</span>, <span class="fl">1</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="op">)</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># here are vertical eyes:</span></span></span>
<span class="r-in"><span><span class="va">df</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">group</span>, y <span class="op">=</span> <span class="va">value</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="stat_eye.html">stat_eye</a></span><span class="op">(</span><span class="op">)</span></span></span>
<span class="r-plt img"><img src="stat_slabinterval-1.png" alt="" width="700" height="433"></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># note the sample size is not automatically incorporated into the</span></span></span>
<span class="r-in"><span><span class="co"># area of the densities in case one wishes to plot densities against</span></span></span>
<span class="r-in"><span><span class="co"># a reference (e.g. a prior distribution).</span></span></span>
<span class="r-in"><span><span class="co"># But you may wish to account for sample size if using these geoms</span></span></span>
<span class="r-in"><span><span class="co"># for something other than visualizing posteriors; in which case</span></span></span>
<span class="r-in"><span><span class="co"># you can use after_stat(f*n):</span></span></span>
<span class="r-in"><span><span class="va">df</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">group</span>, y <span class="op">=</span> <span class="va">value</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="stat_eye.html">stat_eye</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>thickness <span class="op">=</span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes_eval.html" class="external-link">after_stat</a></span><span class="op">(</span><span class="va">pdf</span><span class="op">*</span><span class="va">n</span><span class="op">)</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-plt img"><img src="stat_slabinterval-2.png" alt="" width="700" height="433"></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># EXAMPLES ON ANALYTICAL DISTRIBUTIONS</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="va">dist_df</span> <span class="op">=</span> <span class="fu"><a href="https://tibble.tidyverse.org/reference/tribble.html" class="external-link">tribble</a></span><span class="op">(</span></span></span>
<span class="r-in"><span>  <span class="op">~</span><span class="va">group</span>, <span class="op">~</span><span class="va">subgroup</span>, <span class="op">~</span><span class="va">mean</span>, <span class="op">~</span><span class="va">sd</span>,</span></span>
<span class="r-in"><span>  <span class="st">"a"</span>,          <span class="st">"h"</span>,     <span class="fl">5</span>,   <span class="fl">1</span>,</span></span>
<span class="r-in"><span>  <span class="st">"b"</span>,          <span class="st">"h"</span>,     <span class="fl">7</span>,   <span class="fl">1.5</span>,</span></span>
<span class="r-in"><span>  <span class="st">"c"</span>,          <span class="st">"h"</span>,     <span class="fl">8</span>,   <span class="fl">1</span>,</span></span>
<span class="r-in"><span>  <span class="st">"c"</span>,          <span class="st">"i"</span>,     <span class="fl">9</span>,   <span class="fl">1</span>,</span></span>
<span class="r-in"><span>  <span class="st">"c"</span>,          <span class="st">"j"</span>,     <span class="fl">7</span>,   <span class="fl">1</span></span></span>
<span class="r-in"><span><span class="op">)</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># Using functions from the distributional package (like dist_normal()) with the</span></span></span>
<span class="r-in"><span><span class="co"># dist aesthetic can lead to more compact/expressive specifications</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="va">dist_df</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">group</span>, ydist <span class="op">=</span> <span class="fu"><a href="https://pkg.mitchelloharawild.com/distributional/reference/dist_normal.html" class="external-link">dist_normal</a></span><span class="op">(</span><span class="va">mean</span>, <span class="va">sd</span><span class="op">)</span>, fill <span class="op">=</span> <span class="va">subgroup</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="stat_eye.html">stat_eye</a></span><span class="op">(</span>position <span class="op">=</span> <span class="st">"dodge"</span><span class="op">)</span></span></span>
<span class="r-plt img"><img src="stat_slabinterval-3.png" alt="" width="700" height="433"></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># using the old character vector + args approach</span></span></span>
<span class="r-in"><span><span class="va">dist_df</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">group</span>, dist <span class="op">=</span> <span class="st">"norm"</span>, arg1 <span class="op">=</span> <span class="va">mean</span>, arg2 <span class="op">=</span> <span class="va">sd</span>, fill <span class="op">=</span> <span class="va">subgroup</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="stat_eye.html">stat_eye</a></span><span class="op">(</span>position <span class="op">=</span> <span class="st">"dodge"</span><span class="op">)</span></span></span>
<span class="r-plt img"><img src="stat_slabinterval-4.png" alt="" width="700" height="433"></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># the stat_slabinterval family applies a Jacobian adjustment to densities</span></span></span>
<span class="r-in"><span><span class="co"># when plotting on transformed scales in order to plot them correctly.</span></span></span>
<span class="r-in"><span><span class="co"># It determines the Jacobian using symbolic differentiation if possible,</span></span></span>
<span class="r-in"><span><span class="co"># using stats::D(). If symbolic differentation fails, it falls back</span></span></span>
<span class="r-in"><span><span class="co"># to numericDeriv(), which is less reliable; therefore, it is</span></span></span>
<span class="r-in"><span><span class="co"># advisable to use scale transformation functions that are defined in</span></span></span>
<span class="r-in"><span><span class="co"># terms of basic math functions so that their derivatives can be</span></span></span>
<span class="r-in"><span><span class="co"># determined analytically (most of the transformation functions in the</span></span></span>
<span class="r-in"><span><span class="co"># scales package currently have this property).</span></span></span>
<span class="r-in"><span><span class="co"># For example, here is a log-Normal distribution plotted on the log</span></span></span>
<span class="r-in"><span><span class="co"># scale, where it will appear Normal:</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>dist <span class="op">=</span> <span class="st">"lnorm"</span>, logmean <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/Log.html" class="external-link">log</a></span><span class="op">(</span><span class="fl">10</span><span class="op">)</span>, logsd <span class="op">=</span> <span class="fl">2</span><span class="op">*</span><span class="fu"><a href="https://rdrr.io/r/base/Log.html" class="external-link">log</a></span><span class="op">(</span><span class="fl">10</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>y <span class="op">=</span> <span class="fl">1</span>, dist <span class="op">=</span> <span class="va">dist</span>, arg1 <span class="op">=</span> <span class="va">logmean</span>, arg2 <span class="op">=</span> <span class="va">logsd</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="stat_halfeye.html">stat_halfeye</a></span><span class="op">(</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_continuous.html" class="external-link">scale_x_log10</a></span><span class="op">(</span>breaks <span class="op">=</span> <span class="fl">10</span><span class="op">^</span><span class="fu"><a href="https://rdrr.io/r/base/seq.html" class="external-link">seq</a></span><span class="op">(</span><span class="op">-</span><span class="fl">5</span>,<span class="fl">7</span>, by <span class="op">=</span> <span class="fl">2</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-plt img"><img src="stat_slabinterval-5.png" alt="" width="700" height="433"></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># see vignette("slabinterval") for many more examples.</span></span></span>
<span class="r-in"><span></span></span>
</code></pre></div>
    </div>
  </main><aside class="col-md-3"><nav id="toc"><h2>On this page</h2>
    </nav></aside></div>


    <footer><div class="pkgdown-footer-left">
  <p></p><p>Developed by <a href="https://www.mjskay.com" class="external-link">Matthew Kay</a>.</p>
</div>

<div class="pkgdown-footer-right">
  <p></p><p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.7.</p>
</div>

    </footer></div>

  

  

  </body></html>

