Commit fab894bf authored by Inigo Aldazabal's avatar Inigo Aldazabal

Refresh and remove matplotlib from clean

parent a9648fc8
{ {
"cells": [ "cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Matplotlib](images/matplotlib_logo-s.png)\n",
"\n",
"# Matplotlib"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's take a quick look at the matplotlib essentials.\n",
"\n",
"First let's import the neccesary modules:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"And now let's go with some examples."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1D plot"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A tangent between 0 and 4$\\pi$.\n",
"\n",
"$$y = \\tan(x), \\; x\\in[0., 4\\pi]$$"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1D polar plot "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$\\theta(\\rho) = 2\\pi \\rho, \\; \\rho \\in [0, 2]$"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the function \n",
"\n",
"$$y = \\frac{\\sin(x)}{x}, \\; x\\in[0.1, 6\\pi]$$\n",
"\n",
"and try to \n",
"\n",
"* set the figure *legend*\n",
"* change the *line style*\n",
"\n",
"hint: checkout the [matplotlib examples](http://matplotlib.org/examples/index.html)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# %load files/sol_sinc.py"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -149,10 +31,8 @@ ...@@ -149,10 +31,8 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
...@@ -224,9 +104,7 @@ ...@@ -224,9 +104,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
...@@ -240,9 +118,7 @@ ...@@ -240,9 +118,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
...@@ -256,9 +132,7 @@ ...@@ -256,9 +132,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
...@@ -272,9 +146,7 @@ ...@@ -272,9 +146,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
...@@ -298,9 +170,8 @@ ...@@ -298,9 +170,8 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": null,
"metadata": { "metadata": {
"collapsed": false,
"scrolled": true "scrolled": true
}, },
"outputs": [], "outputs": [],
...@@ -310,10 +181,8 @@ ...@@ -310,10 +181,8 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"#help(integrate)" "#help(integrate)"
...@@ -354,27 +223,21 @@ ...@@ -354,27 +223,21 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
...@@ -399,18 +262,14 @@ ...@@ -399,18 +262,14 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
...@@ -424,18 +283,14 @@ ...@@ -424,18 +283,14 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
...@@ -449,18 +304,14 @@ ...@@ -449,18 +304,14 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
...@@ -474,9 +325,7 @@ ...@@ -474,9 +325,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
...@@ -484,7 +333,7 @@ ...@@ -484,7 +333,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"###Scipy direct method" "## Scipy direct method"
] ]
}, },
{ {
...@@ -497,18 +346,14 @@ ...@@ -497,18 +346,14 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
...@@ -549,9 +394,9 @@ ...@@ -549,9 +394,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.0" "version": "3.6.1"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }
...@@ -32,9 +32,7 @@ ...@@ -32,9 +32,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"import scipy as sp" "import scipy as sp"
...@@ -116,9 +114,7 @@ ...@@ -116,9 +114,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"ndata = 50\n", "ndata = 50\n",
...@@ -137,9 +133,7 @@ ...@@ -137,9 +133,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"plt.plot(tdata, data_pure)\n", "plt.plot(tdata, data_pure)\n",
...@@ -156,9 +150,7 @@ ...@@ -156,9 +150,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"from scipy.optimize import curve_fit\n", "from scipy.optimize import curve_fit\n",
...@@ -180,9 +172,7 @@ ...@@ -180,9 +172,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"plt.plot(tdata, data_pure)\n", "plt.plot(tdata, data_pure)\n",
...@@ -214,7 +204,6 @@ ...@@ -214,7 +204,6 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": false,
"scrolled": true "scrolled": true
}, },
"outputs": [], "outputs": [],
...@@ -268,9 +257,7 @@ ...@@ -268,9 +257,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"import urllib\n", "import urllib\n",
...@@ -282,9 +269,7 @@ ...@@ -282,9 +269,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"years = solarspots[:,0]\n", "years = solarspots[:,0]\n",
...@@ -294,9 +279,7 @@ ...@@ -294,9 +279,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"plt.figure(figsize=(10,6))\n", "plt.figure(figsize=(10,6))\n",
...@@ -335,9 +318,7 @@ ...@@ -335,9 +318,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"spots_fft = fft(spots)" "spots_fft = fft(spots)"
...@@ -346,9 +327,7 @@ ...@@ -346,9 +327,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"plt.scatter(spots_fft.real, spots_fft.imag)\n", "plt.scatter(spots_fft.real, spots_fft.imag)\n",
...@@ -369,9 +348,7 @@ ...@@ -369,9 +348,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"N = spots_fft.size\n", "N = spots_fft.size\n",
...@@ -386,9 +363,7 @@ ...@@ -386,9 +363,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"plt.plot(freq, power)\n", "plt.plot(freq, power)\n",
...@@ -408,9 +383,7 @@ ...@@ -408,9 +383,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"period = 1./freq" "period = 1./freq"
...@@ -419,9 +392,7 @@ ...@@ -419,9 +392,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"plt.plot(period, power)\n", "plt.plot(period, power)\n",
...@@ -443,9 +414,7 @@ ...@@ -443,9 +414,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"max_power_index = np.argmax(power)\n", "max_power_index = np.argmax(power)\n",
...@@ -470,9 +439,7 @@ ...@@ -470,9 +439,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"from scipy import signal\n", "from scipy import signal\n",
...@@ -485,9 +452,7 @@ ...@@ -485,9 +452,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"max_power_index = np.argmax(Pxx_spectrum)\n", "max_power_index = np.argmax(Pxx_spectrum)\n",
...@@ -532,9 +497,9 @@ ...@@ -532,9 +497,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.0" "version": "3.6.1"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment