{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Plot a significance mask\nCompute a linear regression using :func:`pygeode.regress` and use :func:`pygeode.vsigmask` to plot significance\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pygeode as pyg, numpy as np\nimport pylab as pyl\npyl.ioff()\n\nfrom pygeode.tutorial import t3\n\n# Compute regression \nreg = pyg.regress(t3.X1e, t3.Y1, ['time'], output='m,b,r2,p')\n\n\npyl.ioff()\n\n# The significance mask routine takes a signed significance mask as it's main\n# argument. This ensures that regions of significance on opposite sides of the\n# distribution are separated by a filled region. It can be computed as follows\n# from the p-value of the linear regression.\nsigmask = (1 - 0.5*reg.p) * pyg.sign(reg.m)\n\nax1 = pyg.showvar(reg.m, fig=1)\npyg.vsigmask(sigmask, ax1.axes[0], mjsig = 0.99)\n\nax1.axes[0].setp(title = '(a) Significant regions (99%) stippled')\n\nax2 = pyg.showvar(reg.m, fig=1)\npyg.vsigmask(sigmask, ax2.axes[0], \\\n mjsig = 0.95, mjsigp = dict(visible = False), \\\n nsigp = dict(alpha = 0.4, hatch = None, color = 'k'))\n\nax2.axes[0].setp(title = '(b) Non-significant regions (95%) shaded')\n\nax = pyg.plot.grid([[ax1], [ax2]])\npyl.ion()\n\nax.render()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "``reg`` contains a dataset of values from the regression\n\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(reg)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.12" } }, "nbformat": 4, "nbformat_minor": 0 }