arviz 0.23.3__py3-none-any.whl → 1.0.0rc0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- arviz/__init__.py +52 -367
- arviz-1.0.0rc0.dist-info/METADATA +182 -0
- arviz-1.0.0rc0.dist-info/RECORD +5 -0
- {arviz-0.23.3.dist-info → arviz-1.0.0rc0.dist-info}/WHEEL +1 -2
- {arviz-0.23.3.dist-info → arviz-1.0.0rc0.dist-info}/licenses/LICENSE +0 -1
- arviz/data/__init__.py +0 -55
- arviz/data/base.py +0 -596
- arviz/data/converters.py +0 -203
- arviz/data/datasets.py +0 -161
- arviz/data/example_data/code/radon/radon.json +0 -326
- arviz/data/example_data/data/centered_eight.nc +0 -0
- arviz/data/example_data/data/non_centered_eight.nc +0 -0
- arviz/data/example_data/data_local.json +0 -12
- arviz/data/example_data/data_remote.json +0 -58
- arviz/data/inference_data.py +0 -2386
- arviz/data/io_beanmachine.py +0 -112
- arviz/data/io_cmdstan.py +0 -1036
- arviz/data/io_cmdstanpy.py +0 -1233
- arviz/data/io_datatree.py +0 -23
- arviz/data/io_dict.py +0 -462
- arviz/data/io_emcee.py +0 -317
- arviz/data/io_json.py +0 -54
- arviz/data/io_netcdf.py +0 -68
- arviz/data/io_numpyro.py +0 -497
- arviz/data/io_pyjags.py +0 -378
- arviz/data/io_pyro.py +0 -333
- arviz/data/io_pystan.py +0 -1095
- arviz/data/io_zarr.py +0 -46
- arviz/data/utils.py +0 -139
- arviz/labels.py +0 -210
- arviz/plots/__init__.py +0 -61
- arviz/plots/autocorrplot.py +0 -171
- arviz/plots/backends/__init__.py +0 -223
- arviz/plots/backends/bokeh/__init__.py +0 -166
- arviz/plots/backends/bokeh/autocorrplot.py +0 -101
- arviz/plots/backends/bokeh/bfplot.py +0 -23
- arviz/plots/backends/bokeh/bpvplot.py +0 -193
- arviz/plots/backends/bokeh/compareplot.py +0 -167
- arviz/plots/backends/bokeh/densityplot.py +0 -239
- arviz/plots/backends/bokeh/distcomparisonplot.py +0 -23
- arviz/plots/backends/bokeh/distplot.py +0 -183
- arviz/plots/backends/bokeh/dotplot.py +0 -113
- arviz/plots/backends/bokeh/ecdfplot.py +0 -73
- arviz/plots/backends/bokeh/elpdplot.py +0 -203
- arviz/plots/backends/bokeh/energyplot.py +0 -155
- arviz/plots/backends/bokeh/essplot.py +0 -176
- arviz/plots/backends/bokeh/forestplot.py +0 -772
- arviz/plots/backends/bokeh/hdiplot.py +0 -54
- arviz/plots/backends/bokeh/kdeplot.py +0 -268
- arviz/plots/backends/bokeh/khatplot.py +0 -163
- arviz/plots/backends/bokeh/lmplot.py +0 -185
- arviz/plots/backends/bokeh/loopitplot.py +0 -211
- arviz/plots/backends/bokeh/mcseplot.py +0 -184
- arviz/plots/backends/bokeh/pairplot.py +0 -328
- arviz/plots/backends/bokeh/parallelplot.py +0 -81
- arviz/plots/backends/bokeh/posteriorplot.py +0 -324
- arviz/plots/backends/bokeh/ppcplot.py +0 -379
- arviz/plots/backends/bokeh/rankplot.py +0 -149
- arviz/plots/backends/bokeh/separationplot.py +0 -107
- arviz/plots/backends/bokeh/traceplot.py +0 -436
- arviz/plots/backends/bokeh/violinplot.py +0 -164
- arviz/plots/backends/matplotlib/__init__.py +0 -124
- arviz/plots/backends/matplotlib/autocorrplot.py +0 -72
- arviz/plots/backends/matplotlib/bfplot.py +0 -78
- arviz/plots/backends/matplotlib/bpvplot.py +0 -177
- arviz/plots/backends/matplotlib/compareplot.py +0 -135
- arviz/plots/backends/matplotlib/densityplot.py +0 -194
- arviz/plots/backends/matplotlib/distcomparisonplot.py +0 -119
- arviz/plots/backends/matplotlib/distplot.py +0 -178
- arviz/plots/backends/matplotlib/dotplot.py +0 -116
- arviz/plots/backends/matplotlib/ecdfplot.py +0 -70
- arviz/plots/backends/matplotlib/elpdplot.py +0 -189
- arviz/plots/backends/matplotlib/energyplot.py +0 -113
- arviz/plots/backends/matplotlib/essplot.py +0 -180
- arviz/plots/backends/matplotlib/forestplot.py +0 -656
- arviz/plots/backends/matplotlib/hdiplot.py +0 -48
- arviz/plots/backends/matplotlib/kdeplot.py +0 -177
- arviz/plots/backends/matplotlib/khatplot.py +0 -241
- arviz/plots/backends/matplotlib/lmplot.py +0 -149
- arviz/plots/backends/matplotlib/loopitplot.py +0 -144
- arviz/plots/backends/matplotlib/mcseplot.py +0 -161
- arviz/plots/backends/matplotlib/pairplot.py +0 -355
- arviz/plots/backends/matplotlib/parallelplot.py +0 -58
- arviz/plots/backends/matplotlib/posteriorplot.py +0 -348
- arviz/plots/backends/matplotlib/ppcplot.py +0 -478
- arviz/plots/backends/matplotlib/rankplot.py +0 -119
- arviz/plots/backends/matplotlib/separationplot.py +0 -97
- arviz/plots/backends/matplotlib/traceplot.py +0 -526
- arviz/plots/backends/matplotlib/tsplot.py +0 -121
- arviz/plots/backends/matplotlib/violinplot.py +0 -148
- arviz/plots/bfplot.py +0 -128
- arviz/plots/bpvplot.py +0 -308
- arviz/plots/compareplot.py +0 -177
- arviz/plots/densityplot.py +0 -284
- arviz/plots/distcomparisonplot.py +0 -197
- arviz/plots/distplot.py +0 -233
- arviz/plots/dotplot.py +0 -233
- arviz/plots/ecdfplot.py +0 -372
- arviz/plots/elpdplot.py +0 -174
- arviz/plots/energyplot.py +0 -147
- arviz/plots/essplot.py +0 -319
- arviz/plots/forestplot.py +0 -304
- arviz/plots/hdiplot.py +0 -211
- arviz/plots/kdeplot.py +0 -357
- arviz/plots/khatplot.py +0 -236
- arviz/plots/lmplot.py +0 -380
- arviz/plots/loopitplot.py +0 -224
- arviz/plots/mcseplot.py +0 -194
- arviz/plots/pairplot.py +0 -281
- arviz/plots/parallelplot.py +0 -204
- arviz/plots/plot_utils.py +0 -599
- arviz/plots/posteriorplot.py +0 -298
- arviz/plots/ppcplot.py +0 -369
- arviz/plots/rankplot.py +0 -232
- arviz/plots/separationplot.py +0 -167
- arviz/plots/styles/arviz-bluish.mplstyle +0 -1
- arviz/plots/styles/arviz-brownish.mplstyle +0 -1
- arviz/plots/styles/arviz-colors.mplstyle +0 -2
- arviz/plots/styles/arviz-cyanish.mplstyle +0 -1
- arviz/plots/styles/arviz-darkgrid.mplstyle +0 -40
- arviz/plots/styles/arviz-doc.mplstyle +0 -88
- arviz/plots/styles/arviz-docgrid.mplstyle +0 -88
- arviz/plots/styles/arviz-grayscale.mplstyle +0 -41
- arviz/plots/styles/arviz-greenish.mplstyle +0 -1
- arviz/plots/styles/arviz-orangish.mplstyle +0 -1
- arviz/plots/styles/arviz-plasmish.mplstyle +0 -1
- arviz/plots/styles/arviz-purplish.mplstyle +0 -1
- arviz/plots/styles/arviz-redish.mplstyle +0 -1
- arviz/plots/styles/arviz-royish.mplstyle +0 -1
- arviz/plots/styles/arviz-viridish.mplstyle +0 -1
- arviz/plots/styles/arviz-white.mplstyle +0 -40
- arviz/plots/styles/arviz-whitegrid.mplstyle +0 -40
- arviz/plots/traceplot.py +0 -273
- arviz/plots/tsplot.py +0 -440
- arviz/plots/violinplot.py +0 -192
- arviz/preview.py +0 -58
- arviz/py.typed +0 -0
- arviz/rcparams.py +0 -606
- arviz/sel_utils.py +0 -223
- arviz/static/css/style.css +0 -340
- arviz/static/html/icons-svg-inline.html +0 -15
- arviz/stats/__init__.py +0 -37
- arviz/stats/density_utils.py +0 -1013
- arviz/stats/diagnostics.py +0 -1013
- arviz/stats/ecdf_utils.py +0 -324
- arviz/stats/stats.py +0 -2422
- arviz/stats/stats_refitting.py +0 -119
- arviz/stats/stats_utils.py +0 -609
- arviz/tests/__init__.py +0 -1
- arviz/tests/base_tests/__init__.py +0 -1
- arviz/tests/base_tests/test_data.py +0 -1679
- arviz/tests/base_tests/test_data_zarr.py +0 -143
- arviz/tests/base_tests/test_diagnostics.py +0 -511
- arviz/tests/base_tests/test_diagnostics_numba.py +0 -87
- arviz/tests/base_tests/test_helpers.py +0 -18
- arviz/tests/base_tests/test_labels.py +0 -69
- arviz/tests/base_tests/test_plot_utils.py +0 -342
- arviz/tests/base_tests/test_plots_bokeh.py +0 -1288
- arviz/tests/base_tests/test_plots_matplotlib.py +0 -2197
- arviz/tests/base_tests/test_rcparams.py +0 -317
- arviz/tests/base_tests/test_stats.py +0 -925
- arviz/tests/base_tests/test_stats_ecdf_utils.py +0 -166
- arviz/tests/base_tests/test_stats_numba.py +0 -45
- arviz/tests/base_tests/test_stats_utils.py +0 -384
- arviz/tests/base_tests/test_utils.py +0 -376
- arviz/tests/base_tests/test_utils_numba.py +0 -87
- arviz/tests/conftest.py +0 -46
- arviz/tests/external_tests/__init__.py +0 -1
- arviz/tests/external_tests/test_data_beanmachine.py +0 -78
- arviz/tests/external_tests/test_data_cmdstan.py +0 -398
- arviz/tests/external_tests/test_data_cmdstanpy.py +0 -496
- arviz/tests/external_tests/test_data_emcee.py +0 -166
- arviz/tests/external_tests/test_data_numpyro.py +0 -434
- arviz/tests/external_tests/test_data_pyjags.py +0 -119
- arviz/tests/external_tests/test_data_pyro.py +0 -260
- arviz/tests/external_tests/test_data_pystan.py +0 -307
- arviz/tests/helpers.py +0 -677
- arviz/utils.py +0 -773
- arviz/wrappers/__init__.py +0 -13
- arviz/wrappers/base.py +0 -236
- arviz/wrappers/wrap_pymc.py +0 -36
- arviz/wrappers/wrap_stan.py +0 -148
- arviz-0.23.3.dist-info/METADATA +0 -264
- arviz-0.23.3.dist-info/RECORD +0 -183
- arviz-0.23.3.dist-info/top_level.txt +0 -1
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
"""Bokeh Compareplot."""
|
|
2
|
-
|
|
3
|
-
from bokeh.models import Span
|
|
4
|
-
from bokeh.models.annotations import Title, Legend
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
from ...plot_utils import _scale_fig_size
|
|
8
|
-
from .. import show_layout
|
|
9
|
-
from . import backend_kwarg_defaults, create_axes_grid
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def plot_compare(
|
|
13
|
-
ax,
|
|
14
|
-
comp_df,
|
|
15
|
-
legend,
|
|
16
|
-
title,
|
|
17
|
-
figsize,
|
|
18
|
-
plot_ic_diff,
|
|
19
|
-
plot_standard_error,
|
|
20
|
-
insample_dev,
|
|
21
|
-
yticks_pos,
|
|
22
|
-
yticks_labels,
|
|
23
|
-
plot_kwargs,
|
|
24
|
-
textsize,
|
|
25
|
-
information_criterion,
|
|
26
|
-
step,
|
|
27
|
-
backend_kwargs,
|
|
28
|
-
show,
|
|
29
|
-
):
|
|
30
|
-
"""Bokeh compareplot."""
|
|
31
|
-
if backend_kwargs is None:
|
|
32
|
-
backend_kwargs = {}
|
|
33
|
-
|
|
34
|
-
backend_kwargs = {
|
|
35
|
-
**backend_kwarg_defaults(),
|
|
36
|
-
**backend_kwargs,
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
figsize, _, _, _, line_width, _ = _scale_fig_size(figsize, textsize, 1, 1)
|
|
40
|
-
|
|
41
|
-
if ax is None:
|
|
42
|
-
ax = create_axes_grid(
|
|
43
|
-
1,
|
|
44
|
-
figsize=figsize,
|
|
45
|
-
squeeze=True,
|
|
46
|
-
backend_kwargs=backend_kwargs,
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
yticks_pos = list(yticks_pos)
|
|
50
|
-
|
|
51
|
-
labels = []
|
|
52
|
-
|
|
53
|
-
if plot_ic_diff:
|
|
54
|
-
ax.yaxis.ticker = yticks_pos[::2]
|
|
55
|
-
ax.yaxis.major_label_overrides = {
|
|
56
|
-
dtype(key): value
|
|
57
|
-
for key, value in zip(yticks_pos, yticks_labels)
|
|
58
|
-
for dtype in (int, float)
|
|
59
|
-
if (dtype(key) - key == 0)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
# create the coordinates for the errorbars
|
|
63
|
-
err_xs = []
|
|
64
|
-
err_ys = []
|
|
65
|
-
|
|
66
|
-
for x, y, xerr in zip(
|
|
67
|
-
comp_df[information_criterion].iloc[1:], yticks_pos[1::2], comp_df.dse[1:]
|
|
68
|
-
):
|
|
69
|
-
err_xs.append((x - xerr, x + xerr))
|
|
70
|
-
err_ys.append((y, y))
|
|
71
|
-
|
|
72
|
-
# plot them
|
|
73
|
-
dif_tri = ax.scatter(
|
|
74
|
-
comp_df[information_criterion].iloc[1:],
|
|
75
|
-
yticks_pos[1::2],
|
|
76
|
-
line_color=plot_kwargs.get("color_dse", "grey"),
|
|
77
|
-
fill_color=plot_kwargs.get("color_dse", "grey"),
|
|
78
|
-
line_width=2,
|
|
79
|
-
size=6,
|
|
80
|
-
marker="triangle",
|
|
81
|
-
)
|
|
82
|
-
dif_line = ax.multi_line(err_xs, err_ys, line_color=plot_kwargs.get("color_dse", "grey"))
|
|
83
|
-
|
|
84
|
-
labels.append(("ELPD difference", [dif_tri, dif_line]))
|
|
85
|
-
|
|
86
|
-
else:
|
|
87
|
-
ax.yaxis.ticker = yticks_pos[::2]
|
|
88
|
-
ax.yaxis.major_label_overrides = dict(zip(yticks_pos[::2], yticks_labels))
|
|
89
|
-
|
|
90
|
-
elpd_circ = ax.scatter(
|
|
91
|
-
comp_df[information_criterion],
|
|
92
|
-
yticks_pos[::2],
|
|
93
|
-
line_color=plot_kwargs.get("color_ic", "black"),
|
|
94
|
-
fill_color=None,
|
|
95
|
-
line_width=2,
|
|
96
|
-
size=6,
|
|
97
|
-
marker="circle",
|
|
98
|
-
)
|
|
99
|
-
elpd_label = [elpd_circ]
|
|
100
|
-
|
|
101
|
-
if plot_standard_error:
|
|
102
|
-
# create the coordinates for the errorbars
|
|
103
|
-
err_xs = []
|
|
104
|
-
err_ys = []
|
|
105
|
-
|
|
106
|
-
for x, y, xerr in zip(comp_df[information_criterion], yticks_pos[::2], comp_df.se):
|
|
107
|
-
err_xs.append((x - xerr, x + xerr))
|
|
108
|
-
err_ys.append((y, y))
|
|
109
|
-
|
|
110
|
-
# plot them
|
|
111
|
-
elpd_line = ax.multi_line(err_xs, err_ys, line_color=plot_kwargs.get("color_ic", "black"))
|
|
112
|
-
elpd_label.append(elpd_line)
|
|
113
|
-
|
|
114
|
-
labels.append(("ELPD", elpd_label))
|
|
115
|
-
|
|
116
|
-
scale = comp_df["scale"].iloc[0]
|
|
117
|
-
|
|
118
|
-
if insample_dev:
|
|
119
|
-
p_ic = comp_df[f"p_{information_criterion.split('_')[1]}"]
|
|
120
|
-
if scale == "log":
|
|
121
|
-
correction = p_ic
|
|
122
|
-
elif scale == "negative_log":
|
|
123
|
-
correction = -p_ic
|
|
124
|
-
elif scale == "deviance":
|
|
125
|
-
correction = -(2 * p_ic)
|
|
126
|
-
insample_circ = ax.scatter(
|
|
127
|
-
comp_df[information_criterion] + correction,
|
|
128
|
-
yticks_pos[::2],
|
|
129
|
-
line_color=plot_kwargs.get("color_insample_dev", "black"),
|
|
130
|
-
fill_color=plot_kwargs.get("color_insample_dev", "black"),
|
|
131
|
-
line_width=2,
|
|
132
|
-
size=6,
|
|
133
|
-
marker="circle",
|
|
134
|
-
)
|
|
135
|
-
labels.append(("In-sample ELPD", [insample_circ]))
|
|
136
|
-
|
|
137
|
-
vline = Span(
|
|
138
|
-
location=comp_df[information_criterion].iloc[0],
|
|
139
|
-
dimension="height",
|
|
140
|
-
line_color=plot_kwargs.get("color_ls_min_ic", "grey"),
|
|
141
|
-
line_width=line_width,
|
|
142
|
-
line_dash=plot_kwargs.get("ls_min_ic", "dashed"),
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
ax.renderers.append(vline)
|
|
146
|
-
|
|
147
|
-
if legend:
|
|
148
|
-
legend = Legend(items=labels, orientation="vertical", location="top_right")
|
|
149
|
-
ax.add_layout(legend, "above")
|
|
150
|
-
ax.legend.click_policy = "hide"
|
|
151
|
-
|
|
152
|
-
if title:
|
|
153
|
-
_title = Title()
|
|
154
|
-
_title.text = f"Model comparison\n{'higher' if scale == 'log' else 'lower'} is better"
|
|
155
|
-
ax.title = _title
|
|
156
|
-
|
|
157
|
-
if scale == "negative_log":
|
|
158
|
-
scale = "-log"
|
|
159
|
-
|
|
160
|
-
ax.xaxis.axis_label = f"{information_criterion} ({scale})"
|
|
161
|
-
ax.yaxis.axis_label = "ranked models"
|
|
162
|
-
ax.y_range._property_values["start"] = -1 + step # pylint: disable=protected-access
|
|
163
|
-
ax.y_range._property_values["end"] = 0 - step # pylint: disable=protected-access
|
|
164
|
-
|
|
165
|
-
show_layout(ax, show)
|
|
166
|
-
|
|
167
|
-
return ax
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
"""Bokeh Densityplot."""
|
|
2
|
-
|
|
3
|
-
from collections import defaultdict
|
|
4
|
-
from itertools import cycle
|
|
5
|
-
|
|
6
|
-
import matplotlib.pyplot as plt
|
|
7
|
-
import numpy as np
|
|
8
|
-
from bokeh.models.annotations import Legend, Title
|
|
9
|
-
|
|
10
|
-
from ....stats import hdi
|
|
11
|
-
from ....stats.density_utils import get_bins, histogram, kde
|
|
12
|
-
from ...plot_utils import _scale_fig_size, calculate_point_estimate, vectorized_to_hex
|
|
13
|
-
from .. import show_layout
|
|
14
|
-
from . import backend_kwarg_defaults, create_axes_grid
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def plot_density(
|
|
18
|
-
ax,
|
|
19
|
-
all_labels,
|
|
20
|
-
to_plot,
|
|
21
|
-
colors,
|
|
22
|
-
bw,
|
|
23
|
-
circular,
|
|
24
|
-
figsize,
|
|
25
|
-
length_plotters,
|
|
26
|
-
rows,
|
|
27
|
-
cols,
|
|
28
|
-
textsize,
|
|
29
|
-
labeller,
|
|
30
|
-
hdi_prob,
|
|
31
|
-
point_estimate,
|
|
32
|
-
hdi_markers,
|
|
33
|
-
outline,
|
|
34
|
-
shade,
|
|
35
|
-
n_data,
|
|
36
|
-
data_labels,
|
|
37
|
-
backend_kwargs,
|
|
38
|
-
show,
|
|
39
|
-
):
|
|
40
|
-
"""Bokeh density plot."""
|
|
41
|
-
if backend_kwargs is None:
|
|
42
|
-
backend_kwargs = {}
|
|
43
|
-
|
|
44
|
-
backend_kwargs = {
|
|
45
|
-
**backend_kwarg_defaults(),
|
|
46
|
-
**backend_kwargs,
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if colors == "cycle":
|
|
50
|
-
colors = [
|
|
51
|
-
prop
|
|
52
|
-
for _, prop in zip(
|
|
53
|
-
range(n_data), cycle(plt.rcParams["axes.prop_cycle"].by_key()["color"])
|
|
54
|
-
)
|
|
55
|
-
]
|
|
56
|
-
elif isinstance(colors, str):
|
|
57
|
-
colors = [colors for _ in range(n_data)]
|
|
58
|
-
colors = vectorized_to_hex(colors)
|
|
59
|
-
|
|
60
|
-
(figsize, _, _, _, line_width, markersize) = _scale_fig_size(figsize, textsize, rows, cols)
|
|
61
|
-
|
|
62
|
-
if ax is None:
|
|
63
|
-
ax = create_axes_grid(
|
|
64
|
-
length_plotters,
|
|
65
|
-
rows,
|
|
66
|
-
cols,
|
|
67
|
-
figsize=figsize,
|
|
68
|
-
squeeze=False,
|
|
69
|
-
backend_kwargs=backend_kwargs,
|
|
70
|
-
)
|
|
71
|
-
else:
|
|
72
|
-
ax = np.atleast_2d(ax)
|
|
73
|
-
|
|
74
|
-
axis_map = dict(zip(all_labels, (item for item in ax.flatten() if item is not None)))
|
|
75
|
-
|
|
76
|
-
if data_labels is None:
|
|
77
|
-
data_labels = {}
|
|
78
|
-
|
|
79
|
-
legend_items = defaultdict(list)
|
|
80
|
-
for m_idx, plotters in enumerate(to_plot):
|
|
81
|
-
for var_name, selection, isel, values in plotters:
|
|
82
|
-
label = labeller.make_label_vert(var_name, selection, isel)
|
|
83
|
-
|
|
84
|
-
data_label = data_labels[m_idx] if data_labels else None
|
|
85
|
-
|
|
86
|
-
plotted = _d_helper(
|
|
87
|
-
values.flatten(),
|
|
88
|
-
label,
|
|
89
|
-
colors[m_idx],
|
|
90
|
-
bw,
|
|
91
|
-
circular,
|
|
92
|
-
line_width,
|
|
93
|
-
markersize,
|
|
94
|
-
hdi_prob,
|
|
95
|
-
point_estimate,
|
|
96
|
-
hdi_markers,
|
|
97
|
-
outline,
|
|
98
|
-
shade,
|
|
99
|
-
axis_map[label],
|
|
100
|
-
)
|
|
101
|
-
if data_label is not None:
|
|
102
|
-
legend_items[axis_map[label]].append((data_label, plotted))
|
|
103
|
-
|
|
104
|
-
for ax1, legend in legend_items.items():
|
|
105
|
-
legend = Legend(
|
|
106
|
-
items=legend,
|
|
107
|
-
location="center_right",
|
|
108
|
-
orientation="horizontal",
|
|
109
|
-
)
|
|
110
|
-
ax1.add_layout(legend, "above")
|
|
111
|
-
ax1.legend.click_policy = "hide"
|
|
112
|
-
|
|
113
|
-
show_layout(ax, show)
|
|
114
|
-
|
|
115
|
-
return ax
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
def _d_helper(
|
|
119
|
-
vec,
|
|
120
|
-
vname,
|
|
121
|
-
color,
|
|
122
|
-
bw,
|
|
123
|
-
circular,
|
|
124
|
-
line_width,
|
|
125
|
-
markersize,
|
|
126
|
-
hdi_prob,
|
|
127
|
-
point_estimate,
|
|
128
|
-
hdi_markers,
|
|
129
|
-
outline,
|
|
130
|
-
shade,
|
|
131
|
-
ax,
|
|
132
|
-
):
|
|
133
|
-
extra = {}
|
|
134
|
-
plotted = []
|
|
135
|
-
|
|
136
|
-
if vec.dtype.kind == "f":
|
|
137
|
-
if hdi_prob != 1:
|
|
138
|
-
hdi_ = hdi(vec, hdi_prob, multimodal=False)
|
|
139
|
-
new_vec = vec[(vec >= hdi_[0]) & (vec <= hdi_[1])]
|
|
140
|
-
else:
|
|
141
|
-
new_vec = vec
|
|
142
|
-
|
|
143
|
-
x, density = kde(new_vec, circular=circular, bw=bw)
|
|
144
|
-
density *= hdi_prob
|
|
145
|
-
xmin, xmax = x[0], x[-1]
|
|
146
|
-
ymin, ymax = density[0], density[-1]
|
|
147
|
-
|
|
148
|
-
if outline:
|
|
149
|
-
plotted.append(ax.line(x, density, line_color=color, line_width=line_width, **extra))
|
|
150
|
-
plotted.append(
|
|
151
|
-
ax.line(
|
|
152
|
-
[xmin, xmin],
|
|
153
|
-
[-ymin / 100, ymin],
|
|
154
|
-
line_color=color,
|
|
155
|
-
line_dash="solid",
|
|
156
|
-
line_width=line_width,
|
|
157
|
-
muted_color=color,
|
|
158
|
-
muted_alpha=0.2,
|
|
159
|
-
)
|
|
160
|
-
)
|
|
161
|
-
plotted.append(
|
|
162
|
-
ax.line(
|
|
163
|
-
[xmax, xmax],
|
|
164
|
-
[-ymax / 100, ymax],
|
|
165
|
-
line_color=color,
|
|
166
|
-
line_dash="solid",
|
|
167
|
-
line_width=line_width,
|
|
168
|
-
muted_color=color,
|
|
169
|
-
muted_alpha=0.2,
|
|
170
|
-
)
|
|
171
|
-
)
|
|
172
|
-
|
|
173
|
-
if shade:
|
|
174
|
-
plotted.append(
|
|
175
|
-
ax.patch(
|
|
176
|
-
np.r_[x[::-1], x, x[-1:]],
|
|
177
|
-
np.r_[np.zeros_like(x), density, [0]],
|
|
178
|
-
fill_color=color,
|
|
179
|
-
fill_alpha=shade,
|
|
180
|
-
muted_color=color,
|
|
181
|
-
muted_alpha=0.2,
|
|
182
|
-
**extra
|
|
183
|
-
)
|
|
184
|
-
)
|
|
185
|
-
|
|
186
|
-
else:
|
|
187
|
-
xmin, xmax = hdi(vec, hdi_prob, multimodal=False)
|
|
188
|
-
bins = get_bins(vec)
|
|
189
|
-
|
|
190
|
-
_, hist, edges = histogram(vec, bins=bins)
|
|
191
|
-
|
|
192
|
-
if outline:
|
|
193
|
-
plotted.append(
|
|
194
|
-
ax.quad(
|
|
195
|
-
top=hist,
|
|
196
|
-
bottom=0,
|
|
197
|
-
left=edges[:-1],
|
|
198
|
-
right=edges[1:],
|
|
199
|
-
line_color=color,
|
|
200
|
-
fill_color=None,
|
|
201
|
-
muted_color=color,
|
|
202
|
-
muted_alpha=0.2,
|
|
203
|
-
**extra
|
|
204
|
-
)
|
|
205
|
-
)
|
|
206
|
-
else:
|
|
207
|
-
plotted.append(
|
|
208
|
-
ax.quad(
|
|
209
|
-
top=hist,
|
|
210
|
-
bottom=0,
|
|
211
|
-
left=edges[:-1],
|
|
212
|
-
right=edges[1:],
|
|
213
|
-
line_color=color,
|
|
214
|
-
fill_color=color,
|
|
215
|
-
fill_alpha=shade,
|
|
216
|
-
muted_color=color,
|
|
217
|
-
muted_alpha=0.2,
|
|
218
|
-
**extra
|
|
219
|
-
)
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
if hdi_markers:
|
|
223
|
-
plotted.append(ax.diamond(xmin, 0, line_color="black", fill_color=color, size=markersize))
|
|
224
|
-
plotted.append(ax.diamond(xmax, 0, line_color="black", fill_color=color, size=markersize))
|
|
225
|
-
|
|
226
|
-
if point_estimate is not None:
|
|
227
|
-
est = calculate_point_estimate(point_estimate, vec, bw, circular)
|
|
228
|
-
plotted.append(
|
|
229
|
-
ax.scatter(
|
|
230
|
-
est, 0, marker="circle", fill_color=color, line_color="black", size=markersize
|
|
231
|
-
)
|
|
232
|
-
)
|
|
233
|
-
|
|
234
|
-
_title = Title()
|
|
235
|
-
_title.text = vname
|
|
236
|
-
ax.title = _title
|
|
237
|
-
ax.title.text_font_size = "13pt"
|
|
238
|
-
|
|
239
|
-
return plotted
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"""Bokeh Density Comparison plot."""
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def plot_dist_comparison(
|
|
5
|
-
ax,
|
|
6
|
-
nvars,
|
|
7
|
-
ngroups,
|
|
8
|
-
figsize,
|
|
9
|
-
dc_plotters,
|
|
10
|
-
legend,
|
|
11
|
-
groups,
|
|
12
|
-
textsize,
|
|
13
|
-
labeller,
|
|
14
|
-
prior_kwargs,
|
|
15
|
-
posterior_kwargs,
|
|
16
|
-
observed_kwargs,
|
|
17
|
-
backend_kwargs,
|
|
18
|
-
show,
|
|
19
|
-
):
|
|
20
|
-
"""Bokeh Density Comparison plot."""
|
|
21
|
-
raise NotImplementedError(
|
|
22
|
-
"The bokeh backend is still under development. Use matplotlib backend."
|
|
23
|
-
)
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
"""Bokeh Distplot."""
|
|
2
|
-
|
|
3
|
-
import matplotlib.pyplot as plt
|
|
4
|
-
import numpy as np
|
|
5
|
-
|
|
6
|
-
from ....stats.density_utils import get_bins, histogram
|
|
7
|
-
from ...kdeplot import plot_kde
|
|
8
|
-
from ...plot_utils import (
|
|
9
|
-
_scale_fig_size,
|
|
10
|
-
set_bokeh_circular_ticks_labels,
|
|
11
|
-
vectorized_to_hex,
|
|
12
|
-
_init_kwargs_dict,
|
|
13
|
-
)
|
|
14
|
-
from .. import show_layout
|
|
15
|
-
from . import backend_kwarg_defaults, create_axes_grid
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def plot_dist(
|
|
19
|
-
values,
|
|
20
|
-
values2,
|
|
21
|
-
color,
|
|
22
|
-
kind,
|
|
23
|
-
cumulative,
|
|
24
|
-
label,
|
|
25
|
-
rotated,
|
|
26
|
-
rug,
|
|
27
|
-
bw,
|
|
28
|
-
quantiles,
|
|
29
|
-
contour,
|
|
30
|
-
fill_last,
|
|
31
|
-
figsize,
|
|
32
|
-
textsize,
|
|
33
|
-
plot_kwargs,
|
|
34
|
-
fill_kwargs,
|
|
35
|
-
rug_kwargs,
|
|
36
|
-
contour_kwargs,
|
|
37
|
-
contourf_kwargs,
|
|
38
|
-
pcolormesh_kwargs,
|
|
39
|
-
hist_kwargs,
|
|
40
|
-
is_circular,
|
|
41
|
-
ax,
|
|
42
|
-
backend_kwargs,
|
|
43
|
-
show,
|
|
44
|
-
):
|
|
45
|
-
"""Bokeh distplot."""
|
|
46
|
-
backend_kwargs = _init_kwargs_dict(backend_kwargs)
|
|
47
|
-
|
|
48
|
-
backend_kwargs = {
|
|
49
|
-
**backend_kwarg_defaults(),
|
|
50
|
-
**backend_kwargs,
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
figsize, *_ = _scale_fig_size(figsize, textsize)
|
|
54
|
-
|
|
55
|
-
color = vectorized_to_hex(color)
|
|
56
|
-
|
|
57
|
-
hist_kwargs = _init_kwargs_dict(hist_kwargs)
|
|
58
|
-
if kind == "hist":
|
|
59
|
-
hist_kwargs.setdefault("cumulative", cumulative)
|
|
60
|
-
hist_kwargs.setdefault("fill_color", color)
|
|
61
|
-
hist_kwargs.setdefault("line_color", color)
|
|
62
|
-
hist_kwargs.setdefault("line_alpha", 0)
|
|
63
|
-
if label is not None:
|
|
64
|
-
hist_kwargs.setdefault("legend_label", str(label))
|
|
65
|
-
|
|
66
|
-
if ax is None:
|
|
67
|
-
ax = create_axes_grid(
|
|
68
|
-
1,
|
|
69
|
-
figsize=figsize,
|
|
70
|
-
squeeze=True,
|
|
71
|
-
polar=is_circular,
|
|
72
|
-
backend_kwargs=backend_kwargs,
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
if kind == "auto":
|
|
76
|
-
kind = "hist" if values.dtype.kind == "i" else "kde"
|
|
77
|
-
|
|
78
|
-
if kind == "hist":
|
|
79
|
-
_histplot_bokeh_op(
|
|
80
|
-
values=values,
|
|
81
|
-
values2=values2,
|
|
82
|
-
rotated=rotated,
|
|
83
|
-
ax=ax,
|
|
84
|
-
hist_kwargs=hist_kwargs,
|
|
85
|
-
is_circular=is_circular,
|
|
86
|
-
)
|
|
87
|
-
elif kind == "kde":
|
|
88
|
-
plot_kwargs = _init_kwargs_dict(plot_kwargs)
|
|
89
|
-
if color is None:
|
|
90
|
-
color = plt.rcParams["axes.prop_cycle"].by_key()["color"][0]
|
|
91
|
-
plot_kwargs.setdefault("line_color", color)
|
|
92
|
-
legend = label is not None
|
|
93
|
-
|
|
94
|
-
plot_kde(
|
|
95
|
-
values,
|
|
96
|
-
values2,
|
|
97
|
-
cumulative=cumulative,
|
|
98
|
-
rug=rug,
|
|
99
|
-
label=label,
|
|
100
|
-
bw=bw,
|
|
101
|
-
is_circular=is_circular,
|
|
102
|
-
quantiles=quantiles,
|
|
103
|
-
rotated=rotated,
|
|
104
|
-
contour=contour,
|
|
105
|
-
legend=legend,
|
|
106
|
-
fill_last=fill_last,
|
|
107
|
-
plot_kwargs=plot_kwargs,
|
|
108
|
-
fill_kwargs=fill_kwargs,
|
|
109
|
-
rug_kwargs=rug_kwargs,
|
|
110
|
-
contour_kwargs=contour_kwargs,
|
|
111
|
-
contourf_kwargs=contourf_kwargs,
|
|
112
|
-
pcolormesh_kwargs=pcolormesh_kwargs,
|
|
113
|
-
ax=ax,
|
|
114
|
-
backend="bokeh",
|
|
115
|
-
backend_kwargs={},
|
|
116
|
-
show=False,
|
|
117
|
-
)
|
|
118
|
-
else:
|
|
119
|
-
raise TypeError(f'Invalid "kind":{kind}. Select from {{"auto","kde","hist"}}')
|
|
120
|
-
|
|
121
|
-
show_layout(ax, show)
|
|
122
|
-
|
|
123
|
-
return ax
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
def _histplot_bokeh_op(values, values2, rotated, ax, hist_kwargs, is_circular):
|
|
127
|
-
"""Add a histogram for the data to the axes."""
|
|
128
|
-
if values2 is not None:
|
|
129
|
-
raise NotImplementedError("Insert hexbin plot here")
|
|
130
|
-
|
|
131
|
-
color = hist_kwargs.pop("color", False)
|
|
132
|
-
if color:
|
|
133
|
-
hist_kwargs["fill_color"] = color
|
|
134
|
-
hist_kwargs["line_color"] = color
|
|
135
|
-
|
|
136
|
-
bins = hist_kwargs.pop("bins", None)
|
|
137
|
-
if bins is None:
|
|
138
|
-
bins = get_bins(values)
|
|
139
|
-
hist, hist_dens, edges = histogram(np.asarray(values).flatten(), bins=bins)
|
|
140
|
-
if hist_kwargs.pop("density", True):
|
|
141
|
-
hist = hist_dens
|
|
142
|
-
if hist_kwargs.pop("cumulative", False):
|
|
143
|
-
hist = np.cumsum(hist)
|
|
144
|
-
hist /= hist[-1]
|
|
145
|
-
if values.dtype.kind == "i":
|
|
146
|
-
edges = edges.astype(float) - 0.5
|
|
147
|
-
|
|
148
|
-
if is_circular:
|
|
149
|
-
if is_circular == "degrees":
|
|
150
|
-
edges = np.deg2rad(edges)
|
|
151
|
-
labels = ["0°", "45°", "90°", "135°", "180°", "225°", "270°", "315°"]
|
|
152
|
-
else:
|
|
153
|
-
labels = [
|
|
154
|
-
r"0",
|
|
155
|
-
r"π/4",
|
|
156
|
-
r"π/2",
|
|
157
|
-
r"3π/4",
|
|
158
|
-
r"π",
|
|
159
|
-
r"5π/4",
|
|
160
|
-
r"3π/2",
|
|
161
|
-
r"7π/4",
|
|
162
|
-
]
|
|
163
|
-
|
|
164
|
-
delta = np.mean(np.diff(edges) / 2)
|
|
165
|
-
|
|
166
|
-
ax.annular_wedge(
|
|
167
|
-
x=0,
|
|
168
|
-
y=0,
|
|
169
|
-
inner_radius=0,
|
|
170
|
-
outer_radius=hist,
|
|
171
|
-
start_angle=edges[1:] - delta,
|
|
172
|
-
end_angle=edges[:-1] - delta,
|
|
173
|
-
direction="clock",
|
|
174
|
-
**hist_kwargs,
|
|
175
|
-
)
|
|
176
|
-
|
|
177
|
-
ax = set_bokeh_circular_ticks_labels(ax, hist, labels)
|
|
178
|
-
elif rotated:
|
|
179
|
-
ax.quad(top=edges[:-1], bottom=edges[1:], left=0, right=hist, **hist_kwargs)
|
|
180
|
-
else:
|
|
181
|
-
ax.quad(top=hist, bottom=0, left=edges[:-1], right=edges[1:], **hist_kwargs)
|
|
182
|
-
|
|
183
|
-
return ax
|