Skip to content

Commit 63aff59

Browse files
authored
Merge pull request #32 from phobson/add-CIs-to-fitter
Add CIs options to linear fits and bump to version 0.2.1
2 parents b5433aa + e3cf0bc commit 63aff59

21 files changed

+479
-185
lines changed

conda.recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package:
22
name: mpl-probscale
3-
version: 0.2.0dev
3+
version: 0.2.1dev
44

55
source:
66
path: ../

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@
8585
# built documents.
8686
#
8787
# The short X.Y version.
88-
version = '0.2.0'
88+
version = '0.2.1'
8989
# The full version, including alpha/beta/rc tags.
90-
release = '0.2.0'
90+
release = '0.2.1'
9191

9292
# The language for content autogenerated by Sphinx. Refer to documentation
9393
# for a list of supported languages.

docs/tutorial/closer_look_at_viz.ipynb

Lines changed: 81 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -499,15 +499,10 @@
499499
"cell_type": "markdown",
500500
"metadata": {},
501501
"source": [
502-
"## Controlling the aesthetics of the plot elements\n",
503-
"\n",
504-
"As it has been hinted in the examples above, the `probplot` function takes two dictionaries to customize the data series and the best-fit line (`scatter_kws` and `line_kws`, respectively.\n",
505-
"These dictionaries are passed directly to the `plot` method of current axes.\n",
502+
"### Bootstrapped confidence intervals\n",
506503
"\n",
507-
"By default, the data series assumes that `linestyle='none'` and `marker='o'`.\n",
508-
"These can be overwritten through `scatter_kws`\n",
509-
"\n",
510-
"Revisting the previous example, we can customize it like so:"
504+
"Regardless of the scales of the plot (linear, log, or prob), you can add bootstrapped confidence intervals around the best-fit line. \n",
505+
"Simply use the ``estimate_ci=True`` option along with ``bestfit=True``:"
511506
]
512507
},
513508
{
@@ -518,45 +513,16 @@
518513
},
519514
"outputs": [],
520515
"source": [
521-
"scatter_options = dict(\n",
522-
" marker='^',\n",
523-
" markerfacecolor='none',\n",
524-
" markeredgecolor='firebrick',\n",
525-
" markeredgewidth=1.25,\n",
526-
" linestyle='none',\n",
527-
" alpha=0.35,\n",
528-
" zorder=5,\n",
529-
" label='Meal Cost ($)'\n",
530-
")\n",
531-
"\n",
532-
"line_options = dict(\n",
533-
" dashes=(10,2,5,2,10,2),\n",
534-
" color='0.25',\n",
535-
" linewidth=3,\n",
536-
" zorder=10,\n",
537-
" label='Best-fit line'\n",
538-
") \n",
539-
"\n",
540-
"fig, ax = pyplot.subplots(figsize=(4, 6))\n",
541-
"fig = probscale.probplot(tips['total_bill'], ax=ax, plottype='prob', probax='y', bestfit=True, \n",
542-
" datascale='log', problabel='Probabilities', datalabel='Total Bill (USD)',\n",
543-
" scatter_kws=scatter_options, line_kws=line_options)\n",
544-
"ax.legend(loc='upper left')\n",
545-
"ax.set_ylim(bottom=0.1, top=99.9)\n",
546-
"seaborn.despine()"
547-
]
548-
},
549-
{
550-
"cell_type": "raw",
551-
"metadata": {},
552-
"source": [
553-
".. note::\n",
554-
" The ``probplot`` function can take two additional aesthetic parameters:\n",
555-
" `color` and `label`. If provided, `color` will override the marker face color\n",
556-
" and line color options of the `scatter_kws` and `line_kws` parameters, respectively.\n",
557-
" Similarly, the label of the scatter series will be overridden by the explicit parameter.\n",
558-
" It is not recommended that `color` and `label` are used. They exist primarily for \n",
559-
" compatibility with the seaborn package."
516+
"N = 15\n",
517+
"numpy.random.seed(0)\n",
518+
"x = numpy.random.normal(size=N) + numpy.random.uniform(size=N)\n",
519+
"fig, ax = pyplot.subplots(figsize=(8, 4))\n",
520+
"fig = probscale.probplot(x, ax=ax, bestfit=True, estimate_ci=True, \n",
521+
" line_kws={'label': 'BF Line', 'color': 'b'},\n",
522+
" scatter_kws={'label': 'Observations'},\n",
523+
" problabel='Probability (%)')\n",
524+
"ax.legend(loc='lower right')\n",
525+
"seaborn.despine(fig)"
560526
]
561527
},
562528
{
@@ -575,37 +541,10 @@
575541
"You should read that function's docstring for more detailed information.\n",
576542
"But the high-level overview is that there are a couple of parameters (``alpha`` and ``beta``) that you can tweak in the plotting positions calculation.\n",
577543
"\n",
578-
"The most common values can be selected via the ``postype`` parameter and are described as follows:\n",
579-
"\n",
580-
" \"type 4\" (α=0, β=1)\n",
581-
" Linear interpolation of the empirical CDF.\n",
582-
" \"type 5\" or \"hazen\" (α=0.5, β=0.5)\n",
583-
" Piecewise linear interpolation.\n",
584-
" \"type 6\" or \"weibull\" (α=0, β=0)\n",
585-
" Weibull plotting positions. Unbiased exceedance probability\n",
586-
" for all distributions. Recommended for hydrologic applications.\n",
587-
" \"type 7\" (α=1, β=1)\n",
588-
" The default values in R. Not recommended with probability\n",
589-
" scales as the min and max data points get plotting positions\n",
590-
" of 0 and 1, respectively, and therefore cannot be shown.\n",
591-
" \"type 8\" (α=1/3, β=1/3)\n",
592-
" Approximately median-unbiased.\n",
593-
" \"type 9\" or \"blom\" (α=0.375, β=0.375)\n",
594-
" Approximately unbiased positions if the data are normally\n",
595-
" distributed.\n",
596-
" \"median\" (α=0.3175, β=0.3175)\n",
597-
" Median exceedance probabilities for all distributions\n",
598-
" (used in ``scipy.stats.probplot``).\n",
599-
" \"apl\" or \"pwm\" (α=0.35, β=0.35)\n",
600-
" Used with probability-weighted moments.\n",
601-
" \"cunnane\" (α=0.4, β=0.4)\n",
602-
" Nearly unbiased quantiles for normally distributed data.\n",
603-
" This is the default value.\n",
604-
" \"gringorten\" (α=0.44, β=0.44)\n",
605-
" Used for Gumble distributions.\n",
606-
" \n",
544+
"The most common values can be selected via the ``postype`` parameter.\n",
545+
"\n",
607546
"These are controlled via the `pp_kws` parameter in `probplot`\n",
608-
"and are discussed in much more detail in the next tutorial.\n"
547+
"and are discussed in much more detail in the `next tutorial <closer_look_at_plot_pos.html>`_."
609548
]
610549
},
611550
{
@@ -639,6 +578,70 @@
639578
"fig.tight_layout()"
640579
]
641580
},
581+
{
582+
"cell_type": "markdown",
583+
"metadata": {},
584+
"source": [
585+
"## Controlling the aesthetics of the plot elements\n",
586+
"\n",
587+
"As it has been hinted in the examples above, the `probplot` function takes two dictionaries to customize the data series and the best-fit line (`scatter_kws` and `line_kws`, respectively.\n",
588+
"These dictionaries are passed directly to the `plot` method of current axes.\n",
589+
"\n",
590+
"By default, the data series assumes that `linestyle='none'` and `marker='o'`.\n",
591+
"These can be overwritten through `scatter_kws`\n",
592+
"\n",
593+
"Revisting the previous example, we can customize it like so:"
594+
]
595+
},
596+
{
597+
"cell_type": "code",
598+
"execution_count": null,
599+
"metadata": {
600+
"collapsed": false
601+
},
602+
"outputs": [],
603+
"source": [
604+
"scatter_options = dict(\n",
605+
" marker='^',\n",
606+
" markerfacecolor='none',\n",
607+
" markeredgecolor='firebrick',\n",
608+
" markeredgewidth=1.25,\n",
609+
" linestyle='none',\n",
610+
" alpha=0.35,\n",
611+
" zorder=5,\n",
612+
" label='Meal Cost ($)'\n",
613+
")\n",
614+
"\n",
615+
"line_options = dict(\n",
616+
" dashes=(10,2,5,2,10,2),\n",
617+
" color='0.25',\n",
618+
" linewidth=3,\n",
619+
" zorder=10,\n",
620+
" label='Best-fit line'\n",
621+
") \n",
622+
"\n",
623+
"fig, ax = pyplot.subplots(figsize=(4, 6))\n",
624+
"fig = probscale.probplot(tips['total_bill'], ax=ax, plottype='prob', probax='y', bestfit=True, \n",
625+
" datascale='log', problabel='Probabilities', datalabel='Total Bill (USD)',\n",
626+
" scatter_kws=scatter_options, line_kws=line_options)\n",
627+
"ax.legend(loc='upper left')\n",
628+
"ax.set_ylim(bottom=0.1, top=99.9)\n",
629+
"seaborn.despine()"
630+
]
631+
},
632+
{
633+
"cell_type": "raw",
634+
"metadata": {},
635+
"source": [
636+
".. note::\n",
637+
" The ``probplot`` function can take two additional aesthetic parameters:\n",
638+
" `color` and `label`. If provided, `color` will override the marker face color\n",
639+
" and line color options of the `scatter_kws` and `line_kws` parameters, respectively.\n",
640+
" Similarly, the label of the scatter series will be overridden by the explicit parameter.\n",
641+
" It is not recommended that `color` and `label` are used. They exist primarily for \n",
642+
" compatibility with the seaborn package."
643+
]
644+
},
642645
{
643646
"cell_type": "markdown",
644647
"metadata": {},
@@ -716,7 +719,7 @@
716719
"name": "python",
717720
"nbconvert_exporter": "python",
718721
"pygments_lexer": "ipython3",
719-
"version": "3.5.1"
722+
"version": "3.5.2"
720723
}
721724
},
722725
"nbformat": 4,

docs/tutorial/getting_started.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@
294294
" probax='y', # flip the plot\n",
295295
" datascale='log', # scale of the non-probability axis\n",
296296
" bestfit=True, # draw a best-fit line\n",
297+
" estimate_ci=True,\n",
297298
" datalabel='Lognormal Values', # labels and markers...\n",
298299
" problabel='Non-exceedance probability',\n",
299300
" scatter_kws=dict(marker='d', zorder=2, mew=1.25, mec='w', markersize=10),\n",
@@ -388,7 +389,7 @@
388389
"name": "python",
389390
"nbconvert_exporter": "python",
390391
"pygments_lexer": "ipython3",
391-
"version": "3.5.1"
392+
"version": "3.5.2"
392393
}
393394
},
394395
"nbformat": 4,
2.25 KB
Loading
2.95 KB
Loading
-236 Bytes
Loading
6 Bytes
Loading
8.35 KB
Loading
9.71 KB
Loading

0 commit comments

Comments
 (0)