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.
Files changed (185) hide show
  1. arviz/__init__.py +52 -367
  2. arviz-1.0.0rc0.dist-info/METADATA +182 -0
  3. arviz-1.0.0rc0.dist-info/RECORD +5 -0
  4. {arviz-0.23.3.dist-info → arviz-1.0.0rc0.dist-info}/WHEEL +1 -2
  5. {arviz-0.23.3.dist-info → arviz-1.0.0rc0.dist-info}/licenses/LICENSE +0 -1
  6. arviz/data/__init__.py +0 -55
  7. arviz/data/base.py +0 -596
  8. arviz/data/converters.py +0 -203
  9. arviz/data/datasets.py +0 -161
  10. arviz/data/example_data/code/radon/radon.json +0 -326
  11. arviz/data/example_data/data/centered_eight.nc +0 -0
  12. arviz/data/example_data/data/non_centered_eight.nc +0 -0
  13. arviz/data/example_data/data_local.json +0 -12
  14. arviz/data/example_data/data_remote.json +0 -58
  15. arviz/data/inference_data.py +0 -2386
  16. arviz/data/io_beanmachine.py +0 -112
  17. arviz/data/io_cmdstan.py +0 -1036
  18. arviz/data/io_cmdstanpy.py +0 -1233
  19. arviz/data/io_datatree.py +0 -23
  20. arviz/data/io_dict.py +0 -462
  21. arviz/data/io_emcee.py +0 -317
  22. arviz/data/io_json.py +0 -54
  23. arviz/data/io_netcdf.py +0 -68
  24. arviz/data/io_numpyro.py +0 -497
  25. arviz/data/io_pyjags.py +0 -378
  26. arviz/data/io_pyro.py +0 -333
  27. arviz/data/io_pystan.py +0 -1095
  28. arviz/data/io_zarr.py +0 -46
  29. arviz/data/utils.py +0 -139
  30. arviz/labels.py +0 -210
  31. arviz/plots/__init__.py +0 -61
  32. arviz/plots/autocorrplot.py +0 -171
  33. arviz/plots/backends/__init__.py +0 -223
  34. arviz/plots/backends/bokeh/__init__.py +0 -166
  35. arviz/plots/backends/bokeh/autocorrplot.py +0 -101
  36. arviz/plots/backends/bokeh/bfplot.py +0 -23
  37. arviz/plots/backends/bokeh/bpvplot.py +0 -193
  38. arviz/plots/backends/bokeh/compareplot.py +0 -167
  39. arviz/plots/backends/bokeh/densityplot.py +0 -239
  40. arviz/plots/backends/bokeh/distcomparisonplot.py +0 -23
  41. arviz/plots/backends/bokeh/distplot.py +0 -183
  42. arviz/plots/backends/bokeh/dotplot.py +0 -113
  43. arviz/plots/backends/bokeh/ecdfplot.py +0 -73
  44. arviz/plots/backends/bokeh/elpdplot.py +0 -203
  45. arviz/plots/backends/bokeh/energyplot.py +0 -155
  46. arviz/plots/backends/bokeh/essplot.py +0 -176
  47. arviz/plots/backends/bokeh/forestplot.py +0 -772
  48. arviz/plots/backends/bokeh/hdiplot.py +0 -54
  49. arviz/plots/backends/bokeh/kdeplot.py +0 -268
  50. arviz/plots/backends/bokeh/khatplot.py +0 -163
  51. arviz/plots/backends/bokeh/lmplot.py +0 -185
  52. arviz/plots/backends/bokeh/loopitplot.py +0 -211
  53. arviz/plots/backends/bokeh/mcseplot.py +0 -184
  54. arviz/plots/backends/bokeh/pairplot.py +0 -328
  55. arviz/plots/backends/bokeh/parallelplot.py +0 -81
  56. arviz/plots/backends/bokeh/posteriorplot.py +0 -324
  57. arviz/plots/backends/bokeh/ppcplot.py +0 -379
  58. arviz/plots/backends/bokeh/rankplot.py +0 -149
  59. arviz/plots/backends/bokeh/separationplot.py +0 -107
  60. arviz/plots/backends/bokeh/traceplot.py +0 -436
  61. arviz/plots/backends/bokeh/violinplot.py +0 -164
  62. arviz/plots/backends/matplotlib/__init__.py +0 -124
  63. arviz/plots/backends/matplotlib/autocorrplot.py +0 -72
  64. arviz/plots/backends/matplotlib/bfplot.py +0 -78
  65. arviz/plots/backends/matplotlib/bpvplot.py +0 -177
  66. arviz/plots/backends/matplotlib/compareplot.py +0 -135
  67. arviz/plots/backends/matplotlib/densityplot.py +0 -194
  68. arviz/plots/backends/matplotlib/distcomparisonplot.py +0 -119
  69. arviz/plots/backends/matplotlib/distplot.py +0 -178
  70. arviz/plots/backends/matplotlib/dotplot.py +0 -116
  71. arviz/plots/backends/matplotlib/ecdfplot.py +0 -70
  72. arviz/plots/backends/matplotlib/elpdplot.py +0 -189
  73. arviz/plots/backends/matplotlib/energyplot.py +0 -113
  74. arviz/plots/backends/matplotlib/essplot.py +0 -180
  75. arviz/plots/backends/matplotlib/forestplot.py +0 -656
  76. arviz/plots/backends/matplotlib/hdiplot.py +0 -48
  77. arviz/plots/backends/matplotlib/kdeplot.py +0 -177
  78. arviz/plots/backends/matplotlib/khatplot.py +0 -241
  79. arviz/plots/backends/matplotlib/lmplot.py +0 -149
  80. arviz/plots/backends/matplotlib/loopitplot.py +0 -144
  81. arviz/plots/backends/matplotlib/mcseplot.py +0 -161
  82. arviz/plots/backends/matplotlib/pairplot.py +0 -355
  83. arviz/plots/backends/matplotlib/parallelplot.py +0 -58
  84. arviz/plots/backends/matplotlib/posteriorplot.py +0 -348
  85. arviz/plots/backends/matplotlib/ppcplot.py +0 -478
  86. arviz/plots/backends/matplotlib/rankplot.py +0 -119
  87. arviz/plots/backends/matplotlib/separationplot.py +0 -97
  88. arviz/plots/backends/matplotlib/traceplot.py +0 -526
  89. arviz/plots/backends/matplotlib/tsplot.py +0 -121
  90. arviz/plots/backends/matplotlib/violinplot.py +0 -148
  91. arviz/plots/bfplot.py +0 -128
  92. arviz/plots/bpvplot.py +0 -308
  93. arviz/plots/compareplot.py +0 -177
  94. arviz/plots/densityplot.py +0 -284
  95. arviz/plots/distcomparisonplot.py +0 -197
  96. arviz/plots/distplot.py +0 -233
  97. arviz/plots/dotplot.py +0 -233
  98. arviz/plots/ecdfplot.py +0 -372
  99. arviz/plots/elpdplot.py +0 -174
  100. arviz/plots/energyplot.py +0 -147
  101. arviz/plots/essplot.py +0 -319
  102. arviz/plots/forestplot.py +0 -304
  103. arviz/plots/hdiplot.py +0 -211
  104. arviz/plots/kdeplot.py +0 -357
  105. arviz/plots/khatplot.py +0 -236
  106. arviz/plots/lmplot.py +0 -380
  107. arviz/plots/loopitplot.py +0 -224
  108. arviz/plots/mcseplot.py +0 -194
  109. arviz/plots/pairplot.py +0 -281
  110. arviz/plots/parallelplot.py +0 -204
  111. arviz/plots/plot_utils.py +0 -599
  112. arviz/plots/posteriorplot.py +0 -298
  113. arviz/plots/ppcplot.py +0 -369
  114. arviz/plots/rankplot.py +0 -232
  115. arviz/plots/separationplot.py +0 -167
  116. arviz/plots/styles/arviz-bluish.mplstyle +0 -1
  117. arviz/plots/styles/arviz-brownish.mplstyle +0 -1
  118. arviz/plots/styles/arviz-colors.mplstyle +0 -2
  119. arviz/plots/styles/arviz-cyanish.mplstyle +0 -1
  120. arviz/plots/styles/arviz-darkgrid.mplstyle +0 -40
  121. arviz/plots/styles/arviz-doc.mplstyle +0 -88
  122. arviz/plots/styles/arviz-docgrid.mplstyle +0 -88
  123. arviz/plots/styles/arviz-grayscale.mplstyle +0 -41
  124. arviz/plots/styles/arviz-greenish.mplstyle +0 -1
  125. arviz/plots/styles/arviz-orangish.mplstyle +0 -1
  126. arviz/plots/styles/arviz-plasmish.mplstyle +0 -1
  127. arviz/plots/styles/arviz-purplish.mplstyle +0 -1
  128. arviz/plots/styles/arviz-redish.mplstyle +0 -1
  129. arviz/plots/styles/arviz-royish.mplstyle +0 -1
  130. arviz/plots/styles/arviz-viridish.mplstyle +0 -1
  131. arviz/plots/styles/arviz-white.mplstyle +0 -40
  132. arviz/plots/styles/arviz-whitegrid.mplstyle +0 -40
  133. arviz/plots/traceplot.py +0 -273
  134. arviz/plots/tsplot.py +0 -440
  135. arviz/plots/violinplot.py +0 -192
  136. arviz/preview.py +0 -58
  137. arviz/py.typed +0 -0
  138. arviz/rcparams.py +0 -606
  139. arviz/sel_utils.py +0 -223
  140. arviz/static/css/style.css +0 -340
  141. arviz/static/html/icons-svg-inline.html +0 -15
  142. arviz/stats/__init__.py +0 -37
  143. arviz/stats/density_utils.py +0 -1013
  144. arviz/stats/diagnostics.py +0 -1013
  145. arviz/stats/ecdf_utils.py +0 -324
  146. arviz/stats/stats.py +0 -2422
  147. arviz/stats/stats_refitting.py +0 -119
  148. arviz/stats/stats_utils.py +0 -609
  149. arviz/tests/__init__.py +0 -1
  150. arviz/tests/base_tests/__init__.py +0 -1
  151. arviz/tests/base_tests/test_data.py +0 -1679
  152. arviz/tests/base_tests/test_data_zarr.py +0 -143
  153. arviz/tests/base_tests/test_diagnostics.py +0 -511
  154. arviz/tests/base_tests/test_diagnostics_numba.py +0 -87
  155. arviz/tests/base_tests/test_helpers.py +0 -18
  156. arviz/tests/base_tests/test_labels.py +0 -69
  157. arviz/tests/base_tests/test_plot_utils.py +0 -342
  158. arviz/tests/base_tests/test_plots_bokeh.py +0 -1288
  159. arviz/tests/base_tests/test_plots_matplotlib.py +0 -2197
  160. arviz/tests/base_tests/test_rcparams.py +0 -317
  161. arviz/tests/base_tests/test_stats.py +0 -925
  162. arviz/tests/base_tests/test_stats_ecdf_utils.py +0 -166
  163. arviz/tests/base_tests/test_stats_numba.py +0 -45
  164. arviz/tests/base_tests/test_stats_utils.py +0 -384
  165. arviz/tests/base_tests/test_utils.py +0 -376
  166. arviz/tests/base_tests/test_utils_numba.py +0 -87
  167. arviz/tests/conftest.py +0 -46
  168. arviz/tests/external_tests/__init__.py +0 -1
  169. arviz/tests/external_tests/test_data_beanmachine.py +0 -78
  170. arviz/tests/external_tests/test_data_cmdstan.py +0 -398
  171. arviz/tests/external_tests/test_data_cmdstanpy.py +0 -496
  172. arviz/tests/external_tests/test_data_emcee.py +0 -166
  173. arviz/tests/external_tests/test_data_numpyro.py +0 -434
  174. arviz/tests/external_tests/test_data_pyjags.py +0 -119
  175. arviz/tests/external_tests/test_data_pyro.py +0 -260
  176. arviz/tests/external_tests/test_data_pystan.py +0 -307
  177. arviz/tests/helpers.py +0 -677
  178. arviz/utils.py +0 -773
  179. arviz/wrappers/__init__.py +0 -13
  180. arviz/wrappers/base.py +0 -236
  181. arviz/wrappers/wrap_pymc.py +0 -36
  182. arviz/wrappers/wrap_stan.py +0 -148
  183. arviz-0.23.3.dist-info/METADATA +0 -264
  184. arviz-0.23.3.dist-info/RECORD +0 -183
  185. 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