Interactive charts¶
Interactive Vega-Lite charts, see Interactive charts. They need the interactive extra.
forest_chart ¶
forest_chart(
x: RMAResult | RMAMVResult | ChartData,
*,
transf: Callable[[ArrayLike], ndarray] | None = None,
xlab: str | None = None,
refline: float | None = 0.0,
order: Literal['obs', 'weight', 'input'] = 'input',
width: int = 560,
**data_kwargs: Any,
) -> VConcatChart
Return an interactive forest plot: a row per study, then the pooled rows.
Each study is a rule from ci_lb to ci_ub and a square sized by weight; each pooled row is a diamond with its prediction interval as a thin
rule. Hovering a study shows its estimate, interval and weight; clicking a linked study follows its href, and clicking a study highlights it
(selection_point on slab). When x is a fit, the remaining keyword arguments go to
chart_data. The chart inlines its data and uses fixed colours, so it renders alike in any embedding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
RMAResult | RMAMVResult | ChartData
|
An intercept-only fit, or a ChartData (hand-built or from |
required |
transf
|
Callable[[ArrayLike], ndarray] | None
|
Transformation of the estimates and intervals (for example |
None
|
xlab
|
str | None
|
Title of the x axis, default the effect size measure. |
None
|
refline
|
float | None
|
Position of the reference line on the transformed scale; |
0.0
|
order
|
Literal['obs', 'weight', 'input']
|
Order of the study rows: |
'input'
|
width
|
int
|
Plot width in pixels. |
560
|
**data_kwargs
|
Any
|
Passed to |
{}
|
Returns:
| Type | Description |
|---|---|
VConcatChart
|
The chart; |
Raises:
| Type | Description |
|---|---|
InputError
|
|
funnel_chart ¶
funnel_chart(
x: RMAResult | TrimfillResult | ChartData,
*,
yaxis: Literal['sei', 'vi'] = 'sei',
level: float | None = None,
href: Sequence[str | None] | None = None,
slab: Sequence[str] | None = None,
width: int = 420,
) -> LayerChart
Return an interactive funnel plot of a single-level model.
The pseudo-confidence region is estimate +/- z(level) * sei with the y axis reversed, as metafor's funnel() draws it. Each observed study
is a filled circle with a tooltip, a link to its href and a selection_point on slab. A
TrimfillResult draws its imputed studies (fill) as open circles after the observed ones. A
ChartData draws its studies on the untransformed yi scale against the first pooled row's estimate, with
its fill column marking imputed studies. The chart inlines its data and uses fixed colours.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
RMAResult | TrimfillResult | ChartData
|
An intercept-only single-level fit, a trim-and-fill result, or an untransformed |
required |
yaxis
|
Literal['sei', 'vi']
|
|
'sei'
|
level
|
float | None
|
Confidence level in percent of the region, default that of |
None
|
href
|
Sequence[str | None] | None
|
A link per study, for a fit (see chart_data). |
None
|
slab
|
Sequence[str] | None
|
Study labels, for a fit. |
None
|
width
|
int
|
Plot width in pixels. |
420
|
Returns:
| Type | Description |
|---|---|
LayerChart
|
The chart; |
Raises:
| Type | Description |
|---|---|
NotSupportedError
|
|
InputError
|
|
chart_data ¶
chart_data(
x: RMAResult | RMAMVResult,
*,
transf: Callable[[ArrayLike], ndarray] | None = None,
slab: Sequence[str] | None = None,
href: Sequence[str | None] | None = None,
groups: Sequence[str] | None = None,
group_fits: Mapping[str, RMAResult | RMAMVResult]
| None = None,
level: float | None = None,
) -> ChartData
Return the per-study and pooled frames a forest or funnel chart draws.
Per-study intervals are yi +/- z(level) * sqrt(vi), as metafor's forest() draws them, then passed through transf. Weights are
weights_() of x, as percentages. The pooled rows come from predict(x, transf=transf) for x, then one row per entry of group_fits,
labelled by its key, in the mapping's order. groups gives each study's group label; it is required when group_fits is given and must have one
entry per study of x. slab, href and groups index the studies of x before the omission of studies with a missing yi or vi.
href gives each study a link (any URL, including an in-page #anchor); None leaves that study unlinked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
RMAResult | RMAMVResult
|
required | |
transf
|
Callable[[ArrayLike], ndarray] | None
|
Transformation of the intervals and the pooled rows (for example |
None
|
slab
|
Sequence[str] | None
|
Study labels, default those of |
None
|
href
|
Sequence[str | None] | None
|
A link per study. |
None
|
groups
|
Sequence[str] | None
|
A group label per study. |
None
|
group_fits
|
Mapping[str, RMAResult | RMAMVResult] | None
|
A fit per group label, drawn as an extra pooled row. |
None
|
level
|
float | None
|
Confidence level in percent, default that of |
None
|
Returns:
| Type | Description |
|---|---|
ChartData
|
The frames, a ChartData. |
Raises:
| Type | Description |
|---|---|
InputError
|
|
ChartData
dataclass
¶
The frames a chart draws: one row per study, and one row per pooled estimate.
studies has the columns slab, yi, vi, sei, ci_lb, ci_ub, weight, order, href, group, fill (ci_lb and ci_ub on the transformed
scale when transformed; weight in percent; order the position of the study in the input); pooled has label, estimate, ci_lb, ci_ub,
pi_lb, pi_ub, k, tau2, I2, one row per fit.