| 288 | |
| 289 | |
| 290 | def bootstrap_plot( |
| 291 | series: Series, |
| 292 | fig: Figure | None = None, |
| 293 | size: int = 50, |
| 294 | samples: int = 500, |
| 295 | **kwds, |
| 296 | ) -> Figure: |
| 297 | import matplotlib.pyplot as plt |
| 298 | |
| 299 | # TODO: is the failure mentioned below still relevant? |
| 300 | # random.sample(ndarray, int) fails on python 3.3, sigh |
| 301 | data = list(series.values) |
| 302 | samplings = [random.sample(data, size) for _ in range(samples)] |
| 303 | |
| 304 | means = np.array([np.mean(sampling) for sampling in samplings]) |
| 305 | medians = np.array([np.median(sampling) for sampling in samplings]) |
| 306 | midranges = np.array( |
| 307 | [(min(sampling) + max(sampling)) * 0.5 for sampling in samplings] |
| 308 | ) |
| 309 | if fig is None: |
| 310 | fig = plt.figure() |
| 311 | x = list(range(samples)) |
| 312 | axes = [] |
| 313 | ax1 = fig.add_subplot(2, 3, 1) |
| 314 | ax1.set_xlabel("Sample") |
| 315 | axes.append(ax1) |
| 316 | ax1.plot(x, means, **kwds) |
| 317 | ax2 = fig.add_subplot(2, 3, 2) |
| 318 | ax2.set_xlabel("Sample") |
| 319 | axes.append(ax2) |
| 320 | ax2.plot(x, medians, **kwds) |
| 321 | ax3 = fig.add_subplot(2, 3, 3) |
| 322 | ax3.set_xlabel("Sample") |
| 323 | axes.append(ax3) |
| 324 | ax3.plot(x, midranges, **kwds) |
| 325 | ax4 = fig.add_subplot(2, 3, 4) |
| 326 | ax4.set_xlabel("Mean") |
| 327 | axes.append(ax4) |
| 328 | ax4.hist(means, **kwds) |
| 329 | ax5 = fig.add_subplot(2, 3, 5) |
| 330 | ax5.set_xlabel("Median") |
| 331 | axes.append(ax5) |
| 332 | ax5.hist(medians, **kwds) |
| 333 | ax6 = fig.add_subplot(2, 3, 6) |
| 334 | ax6.set_xlabel("Midrange") |
| 335 | axes.append(ax6) |
| 336 | ax6.hist(midranges, **kwds) |
| 337 | for axis in axes: |
| 338 | plt.setp(axis.get_xticklabels(), fontsize=8) |
| 339 | plt.setp(axis.get_yticklabels(), fontsize=8) |
| 340 | if do_adjust_figure(fig): |
| 341 | plt.tight_layout() |
| 342 | return fig |
| 343 | |
| 344 | |
| 345 | def parallel_coordinates( |