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
arviz/plots/distplot.py DELETED
@@ -1,233 +0,0 @@
1
- # pylint: disable=unexpected-keyword-arg
2
- """Plot distribution as histogram or kernel density estimates."""
3
- import numpy as np
4
- import xarray as xr
5
-
6
- from ..data import InferenceData
7
- from ..rcparams import rcParams
8
- from .plot_utils import get_plotting_function
9
-
10
-
11
- def plot_dist(
12
- values,
13
- values2=None,
14
- color="C0",
15
- kind="auto",
16
- cumulative=False,
17
- label=None,
18
- rotated=False,
19
- rug=False,
20
- bw="default",
21
- quantiles=None,
22
- contour=True,
23
- fill_last=True,
24
- figsize=None,
25
- textsize=None,
26
- plot_kwargs=None,
27
- fill_kwargs=None,
28
- rug_kwargs=None,
29
- contour_kwargs=None,
30
- contourf_kwargs=None,
31
- pcolormesh_kwargs=None,
32
- hist_kwargs=None,
33
- is_circular=False,
34
- ax=None,
35
- backend=None,
36
- backend_kwargs=None,
37
- show=None,
38
- **kwargs,
39
- ):
40
- r"""Plot distribution as histogram or kernel density estimates.
41
-
42
- By default continuous variables are plotted using KDEs and discrete ones using histograms
43
-
44
- Parameters
45
- ----------
46
- values : array-like
47
- Values to plot from an unknown continuous or discrete distribution.
48
- values2 : array-like, optional
49
- Values to plot. If present, a 2D KDE or a hexbin will be estimated.
50
- color : string
51
- valid matplotlib color.
52
- kind : string, default "auto"
53
- By default ("auto") continuous variables will use the kind defined by rcParam
54
- ``plot.density_kind`` and discrete ones will use histograms.
55
- To override this use "hist" to plot histograms and "kde" for KDEs.
56
- cumulative : bool, default False
57
- If true plot the estimated cumulative distribution function. Defaults to False.
58
- Ignored for 2D KDE.
59
- label : string
60
- Text to include as part of the legend.
61
- rotated : bool, default False
62
- Whether to rotate the 1D KDE plot 90 degrees.
63
- rug : bool, default False
64
- Add a `rug plot <https://en.wikipedia.org/wiki/Rug_plot>`_ for a specific subset
65
- of values. Ignored for 2D KDE.
66
- bw : float or str, optional
67
- If numeric, indicates the bandwidth and must be positive.
68
- If str, indicates the method to estimate the bandwidth and must be
69
- one of "scott", "silverman", "isj" or "experimental" when ``is_circular`` is False
70
- and "taylor" (for now) when ``is_circular`` is True.
71
- Defaults to "experimental" when variable is not circular and "taylor" when it is.
72
- quantiles : list, optional
73
- Quantiles in ascending order used to segment the KDE. Use [.25, .5, .75] for quartiles.
74
- contour : bool, default True
75
- If True plot the 2D KDE using contours, otherwise plot a smooth 2D KDE.
76
- fill_last : bool, default True
77
- If True fill the last contour of the 2D KDE plot.
78
- figsize : (float, float), optional
79
- Figure size. If `None` it will be defined automatically.
80
- textsize : float, optional
81
- Text size scaling factor for labels, titles and lines. If `None` it will be autoscaled based
82
- on `figsize`. Not implemented for bokeh backend.
83
- plot_kwargs : dict
84
- Keywords passed to the pdf line of a 1D KDE. Passed to :func:`arviz.plot_kde` as
85
- ``plot_kwargs``.
86
- fill_kwargs : dict
87
- Keywords passed to the fill under the line (use fill_kwargs={'alpha': 0} to disable fill).
88
- Ignored for 2D KDE. Passed to :func:`arviz.plot_kde` as ``fill_kwargs``.
89
- rug_kwargs : dict
90
- Keywords passed to the rug plot. Ignored if ``rug=False`` or for 2D KDE
91
- Use ``space`` keyword (float) to control the position of the rugplot.
92
- The larger this number the lower the rugplot. Passed to
93
- :func:`arviz.plot_kde` as ``rug_kwargs``.
94
- contour_kwargs : dict
95
- Keywords passed to the contourplot. Ignored for 1D KDE.
96
- contourf_kwargs : dict
97
- Keywords passed to :meth:`matplotlib.axes.Axes.contourf`. Ignored for 1D KDE.
98
- pcolormesh_kwargs : dict
99
- Keywords passed to :meth:`matplotlib.axes.Axes.pcolormesh`. Ignored for 1D KDE.
100
- hist_kwargs : dict
101
- Keyword arguments used to customize the histogram. Ignored when plotting a KDE.
102
- They are passed to :meth:`matplotlib.axes.Axes.hist` if using matplotlib,
103
- or to :meth:`bokeh.plotting.figure.quad` if using bokeh. In bokeh case,
104
- the following extra keywords are also supported:
105
-
106
- * ``color``: replaces the ``fill_color`` and ``line_color`` of the ``quad`` method
107
- * ``bins``: taken from ``hist_kwargs`` and passed to :func:`numpy.histogram` instead
108
- * ``density``: normalize histogram to represent a probability density function,
109
- Defaults to ``True``
110
-
111
- * ``cumulative``: plot the cumulative counts. Defaults to ``False``.
112
-
113
- is_circular : {False, True, "radians", "degrees"}, default False
114
- Select input type {"radians", "degrees"} for circular histogram or KDE plot. If True,
115
- default input type is "radians". When this argument is present, it interprets the
116
- values passed are from a circular variable measured in radians and a circular KDE is
117
- used. Inputs in "degrees" will undergo an internal conversion to radians. Only valid
118
- for 1D KDE.
119
- ax : matplotlib_axes or bokeh_figure, optional
120
- Matplotlib or bokeh targets on which to plot. If not supplied, Arviz will create
121
- its own plot area (and return it).
122
- backend : {"matplotlib", "bokeh"}, default "matplotlib"
123
- Select plotting backend.
124
- backend_kwargs :dict, optional
125
- These are kwargs specific to the backend being used, passed to
126
- :func:`matplotlib.pyplot.subplots` or :class:`bokeh.plotting.figure`.
127
- For additional documentation check the plotting method of the backend.
128
- show : bool, optional
129
- Call backend show function.
130
-
131
- Returns
132
- -------
133
- axes : matplotlib axes or bokeh figure
134
-
135
- See Also
136
- --------
137
- plot_posterior : Plot Posterior densities in the style of John K. Kruschke's book.
138
- plot_density : Generate KDE plots for continuous variables and histograms for discrete ones.
139
- plot_kde : 1D or 2D KDE plot taking into account boundary conditions.
140
-
141
- Examples
142
- --------
143
- Plot an integer distribution
144
-
145
- .. plot::
146
- :context: close-figs
147
-
148
- >>> import numpy as np
149
- >>> import arviz as az
150
- >>> a = np.random.poisson(4, 1000)
151
- >>> az.plot_dist(a)
152
-
153
- Plot a continuous distribution
154
-
155
- .. plot::
156
- :context: close-figs
157
-
158
- >>> b = np.random.normal(0, 1, 1000)
159
- >>> az.plot_dist(b)
160
-
161
- Add a rug under the Gaussian distribution
162
-
163
- .. plot::
164
- :context: close-figs
165
-
166
- >>> az.plot_dist(b, rug=True)
167
-
168
- Segment into quantiles
169
-
170
- .. plot::
171
- :context: close-figs
172
-
173
- >>> az.plot_dist(b, rug=True, quantiles=[.25, .5, .75])
174
-
175
- Plot as the cumulative distribution
176
-
177
- .. plot::
178
- :context: close-figs
179
-
180
- >>> az.plot_dist(b, rug=True, quantiles=[.25, .5, .75], cumulative=True)
181
- """
182
- values = np.asarray(values)
183
-
184
- if isinstance(values, (InferenceData, xr.Dataset)):
185
- raise ValueError(
186
- "InferenceData or xarray.Dataset object detected,"
187
- " use plot_posterior, plot_density or plot_pair"
188
- " instead of plot_dist"
189
- )
190
-
191
- if kind not in ["auto", "kde", "hist"]:
192
- raise TypeError(f'Invalid "kind":{kind}. Select from {{"auto","kde","hist"}}')
193
-
194
- if kind == "auto":
195
- kind = "hist" if values.dtype.kind == "i" else rcParams["plot.density_kind"]
196
-
197
- dist_plot_args = dict(
198
- # User Facing API that can be simplified
199
- values=values,
200
- values2=values2,
201
- color=color,
202
- kind=kind,
203
- cumulative=cumulative,
204
- label=label,
205
- rotated=rotated,
206
- rug=rug,
207
- bw=bw,
208
- quantiles=quantiles,
209
- contour=contour,
210
- fill_last=fill_last,
211
- figsize=figsize,
212
- textsize=textsize,
213
- plot_kwargs=plot_kwargs,
214
- fill_kwargs=fill_kwargs,
215
- rug_kwargs=rug_kwargs,
216
- contour_kwargs=contour_kwargs,
217
- contourf_kwargs=contourf_kwargs,
218
- pcolormesh_kwargs=pcolormesh_kwargs,
219
- hist_kwargs=hist_kwargs,
220
- ax=ax,
221
- backend_kwargs=backend_kwargs,
222
- is_circular=is_circular,
223
- show=show,
224
- **kwargs,
225
- )
226
-
227
- if backend is None:
228
- backend = rcParams["plot.backend"]
229
- backend = backend.lower()
230
-
231
- plot = get_plotting_function("plot_dist", "distplot", backend)
232
- ax = plot(**dist_plot_args)
233
- return ax
arviz/plots/dotplot.py DELETED
@@ -1,233 +0,0 @@
1
- """Plot distribution as dot plot or quantile dot plot."""
2
-
3
- import numpy as np
4
-
5
-
6
- from ..rcparams import rcParams
7
- from .plot_utils import get_plotting_function
8
-
9
-
10
- def plot_dot(
11
- values,
12
- binwidth=None,
13
- dotsize=1,
14
- stackratio=1,
15
- hdi_prob=None,
16
- rotated=False,
17
- dotcolor="C0",
18
- intervalcolor="C3",
19
- markersize=None,
20
- markercolor="C0",
21
- marker="o",
22
- figsize=None,
23
- linewidth=None,
24
- point_estimate="auto",
25
- nquantiles=50,
26
- quartiles=True,
27
- point_interval=False,
28
- ax=None,
29
- show=None,
30
- plot_kwargs=None,
31
- backend=None,
32
- backend_kwargs=None,
33
- **kwargs
34
- ):
35
- r"""Plot distribution as dot plot or quantile dot plot.
36
-
37
- This function uses the Wilkinson's Algorithm [1]_ to allot dots to bins.
38
- The quantile dot plots was inspired from [2]_.
39
-
40
- Parameters
41
- ----------
42
- values : array-like
43
- Values to plot from an unknown continuous or discrete distribution.
44
- binwidth : float, optional
45
- Width of the bin for drawing the dot plot.
46
- dotsize : float, default 1
47
- The size of the dots relative to the bin width. The default makes dots be
48
- just about as wide as the bin width.
49
- stackratio : float, default 1
50
- The distance between the center of the dots in the same stack relative to the bin height.
51
- The default makes dots in the same stack just touch each other.
52
- point_interval : bool, default False
53
- Plots the point interval. Uses ``hdi_prob`` to plot the HDI interval
54
- point_estimate : str, optional
55
- Plot point estimate per variable. Values should be ``mean``, ``median``, ``mode`` or None.
56
- Defaults to ``auto`` i.e. it falls back to default set in rcParams.
57
- dotcolor : string, optional
58
- The color of the dots. Should be a valid matplotlib color.
59
- intervalcolor : string, optional
60
- The color of the interval. Should be a valid matplotlib color.
61
- linewidth : int, default None
62
- Line width throughout. If None it will be autoscaled based on `figsize`.
63
- markersize : int, default None
64
- Markersize throughout. If None it will be autoscaled based on `figsize`.
65
- markercolor : string, optional
66
- The color of the marker when plot_interval is True. Should be a valid matplotlib color.
67
- marker : string, default "o"
68
- The shape of the marker. Valid for matplotlib backend.
69
- hdi_prob : float, optional
70
- Valid only when point_interval is True. Plots HDI for chosen percentage of density.
71
- Defaults to ``stats.ci_prob`` rcParam. See :ref:`this section <common_hdi_prob>`
72
- for usage examples.
73
- rotated : bool, default False
74
- Whether to rotate the dot plot by 90 degrees.
75
- nquantiles : int, default 50
76
- Number of quantiles to plot, used for quantile dot plots.
77
- quartiles : bool, default True
78
- If True then the quartile interval will be plotted with the HDI.
79
- figsize : (float,float), optional
80
- Figure size. If ``None`` it will be defined automatically.
81
- plot_kwargs : dict, optional
82
- Keywords passed for customizing the dots. Passed to :class:`mpl:matplotlib.patches.Circle`
83
- in matplotlib and :meth:`bokeh.plotting.figure.circle` in bokeh.
84
- backend :{"matplotlib", "bokeh"}, default "matplotlib"
85
- Select plotting backend.
86
- ax : axes, optional
87
- Matplotlib_axes or bokeh_figure.
88
- show : bool, optional
89
- Call backend show function.
90
- backend_kwargs : dict, optional
91
- These are kwargs specific to the backend being used, passed to
92
- :func:`matplotlib.pyplot.subplots` or :class:`bokeh.plotting.figure`.
93
- For additional documentation check the plotting method of the backend.
94
-
95
- Returns
96
- -------
97
- axes : matplotlib_axes or bokeh_figure
98
-
99
- See Also
100
- --------
101
- plot_dist : Plot distribution as histogram or kernel density estimates.
102
-
103
- References
104
- ----------
105
- .. [1] Leland Wilkinson (1999) Dot Plots, The American Statistician, 53:3, 276-281,
106
- DOI: 10.1080/00031305.1999.10474474
107
- .. [2] Matthew Kay, Tara Kola, Jessica R. Hullman,
108
- and Sean A. Munson. 2016. When (ish) is My Bus? User-centered Visualizations of Uncertainty
109
- in Everyday, Mobile Predictive Systems. DOI:https://doi.org/10.1145/2858036.2858558
110
-
111
- Examples
112
- --------
113
- Plot dot plot for a set of data points
114
-
115
- .. plot::
116
- :context: close-figs
117
-
118
- >>> import arviz as az
119
- >>> import numpy as np
120
- >>> values = np.random.normal(0, 1, 500)
121
- >>> az.plot_dot(values)
122
-
123
- Manually adjust number of quantiles to plot
124
-
125
- .. plot::
126
- :context: close-figs
127
-
128
- >>> az.plot_dot(values, nquantiles=100)
129
-
130
- Add a point interval under the dot plot
131
-
132
- .. plot::
133
- :context: close-figs
134
-
135
- >>> az.plot_dot(values, point_interval=True)
136
-
137
- Rotate the dot plots by 90 degrees i.e swap x and y axis
138
-
139
- .. plot::
140
- :context: close-figs
141
-
142
- >>> az.plot_dot(values, point_interval=True, rotated=True)
143
-
144
- """
145
- if nquantiles == 0:
146
- raise ValueError("Number of quantiles should be greater than 0")
147
-
148
- if marker != "o" and backend == "bokeh":
149
- raise ValueError("marker argument is valid only for matplotlib backend")
150
-
151
- values = np.ravel(values)
152
- values = values[np.isfinite(values)]
153
- values.sort()
154
-
155
- if hdi_prob is None:
156
- hdi_prob = rcParams["stats.ci_prob"]
157
- elif not 1 >= hdi_prob > 0:
158
- raise ValueError("The value of hdi_prob should be in the interval (0, 1]")
159
-
160
- if point_estimate == "auto":
161
- point_estimate = rcParams["plot.point_estimate"]
162
- elif point_estimate not in {"mean", "median", "mode", None}:
163
- raise ValueError("The value of point_estimate must be either mean, median, mode or None.")
164
-
165
- if not isinstance(nquantiles, int):
166
- raise TypeError("nquantiles must be of integer type, refer to docs for further details")
167
-
168
- dot_plot_args = dict(
169
- values=values,
170
- binwidth=binwidth,
171
- dotsize=dotsize,
172
- stackratio=stackratio,
173
- hdi_prob=hdi_prob,
174
- quartiles=quartiles,
175
- rotated=rotated,
176
- dotcolor=dotcolor,
177
- intervalcolor=intervalcolor,
178
- markersize=markersize,
179
- markercolor=markercolor,
180
- marker=marker,
181
- figsize=figsize,
182
- linewidth=linewidth,
183
- point_estimate=point_estimate,
184
- nquantiles=nquantiles,
185
- point_interval=point_interval,
186
- ax=ax,
187
- show=show,
188
- backend_kwargs=backend_kwargs,
189
- plot_kwargs=plot_kwargs,
190
- **kwargs
191
- )
192
-
193
- if backend is None:
194
- backend = rcParams["plot.backend"]
195
- backend = backend.lower()
196
-
197
- plot = get_plotting_function("plot_dot", "dotplot", backend)
198
- ax = plot(**dot_plot_args)
199
-
200
- return ax
201
-
202
-
203
- def wilkinson_algorithm(values, binwidth):
204
- """Wilkinson's algorithm to distribute dots into horizontal stacks."""
205
- ndots = len(values)
206
- count = 0
207
- stack_locs, stack_counts = [], []
208
-
209
- while count < ndots:
210
- stack_first_dot = values[count]
211
- num_dots_stack = 0
212
- while values[count] < (binwidth + stack_first_dot):
213
- num_dots_stack += 1
214
- count += 1
215
- if count == ndots:
216
- break
217
- stack_locs.append((stack_first_dot + values[count - 1]) / 2)
218
- stack_counts.append(num_dots_stack)
219
-
220
- return stack_locs, stack_counts
221
-
222
-
223
- def layout_stacks(stack_locs, stack_counts, binwidth, stackratio, rotated):
224
- """Use count and location of stacks to get coordinates of dots."""
225
- dotheight = stackratio * binwidth
226
- binradius = binwidth / 2
227
-
228
- x = np.repeat(stack_locs, stack_counts)
229
- y = np.hstack([dotheight * np.arange(count) + binradius for count in stack_counts])
230
- if rotated:
231
- x, y = y, x
232
-
233
- return x, y