no commit message

parent b9a71a95
{ {
"cells": [ "cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'LC_ALL': 'en_US.UTF-8',\n",
" 'JUPYTERHUB_CLIENT_ID': 'jupyterhub-user-d2e4b375a36b4088c1c267af139bd27b',\n",
" 'JUPYTERHUB_ADMIN_ACCESS': '1',\n",
" 'LANG': 'en_US.UTF-8',\n",
" 'HOSTNAME': '8ddd50d99808',\n",
" 'NB_UID': '1000',\n",
" 'CONDA_DIR': '/opt/conda',\n",
" 'CONDA_VERSION': '4.7.12',\n",
" 'JUPYTERHUB_ACTIVITY_URL': 'http://moocrr_jupyterhub:8080/moocrr/jupyter/hub/api/users/d2e4b375a36b4088c1c267af139bd27b/activity',\n",
" 'JUPYTERHUB_BASE_URL': '/moocrr/jupyter/',\n",
" 'PWD': '/home/jovyan',\n",
" 'HOME': '/home/jovyan',\n",
" 'MINICONDA_MD5': '81c773ff87af5cfac79ab862942ab6b3',\n",
" 'JUPYTERHUB_USER': 'd2e4b375a36b4088c1c267af139bd27b',\n",
" 'DEBIAN_FRONTEND': 'noninteractive',\n",
" 'GITLAB_PROJECT': 'mooc-rr',\n",
" 'NB_USER': 'jovyan',\n",
" 'JUPYTERHUB_SERVICE_PREFIX': '/moocrr/jupyter/user/d2e4b375a36b4088c1c267af139bd27b/',\n",
" 'USER_PASSWORD': '9756d5a792',\n",
" 'JUPYTERHUB_SERVER_NAME': '',\n",
" 'SHELL': '/bin/bash',\n",
" 'MEM_LIMIT': '524288000',\n",
" 'JUPYTERHUB_API_URL': 'http://moocrr_jupyterhub:8080/moocrr/jupyter/hub/api',\n",
" 'SHLVL': '0',\n",
" 'LANGUAGE': 'en_US.UTF-8',\n",
" 'JUPYTERHUB_HOST': '',\n",
" 'JPY_API_TOKEN': '<hidden>',\n",
" 'XDG_CACHE_HOME': '/home/jovyan/.cache/',\n",
" 'JUPYTERHUB_OAUTH_CALLBACK_URL': '/moocrr/jupyter/user/d2e4b375a36b4088c1c267af139bd27b/oauth_callback',\n",
" 'NB_GID': '100',\n",
" 'JUPYTERHUB_API_TOKEN': '<hidden>',\n",
" 'PATH': '/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',\n",
" 'MINICONDA_VERSION': '4.7.12.1',\n",
" 'KERNEL_LAUNCH_TIMEOUT': '40',\n",
" 'JPY_PARENT_PID': '7',\n",
" 'TERM': 'xterm-color',\n",
" 'CLICOLOR': '1',\n",
" 'PAGER': 'cat',\n",
" 'GIT_PAGER': 'cat',\n",
" 'MPLBACKEND': 'module://ipykernel.pylab.backend_inline'}"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%env"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# %load http://matplotlib.org/mpl_examples/pylab_examples/contour_demo.py\n",
"\"\"\"\n",
"Illustrate simple contour plotting, contours on an image with\n",
"a colorbar for the contours, and labelled contours.\n",
"\n",
"See also contour_image.py.\n",
"\"\"\"\n",
"import matplotlib\n",
"import numpy as np\n",
"import matplotlib.cm as cm\n",
"import matplotlib.mlab as mlab\n",
"import matplotlib.pyplot as plt\n",
"\n",
"matplotlib.rcParams['xtick.direction'] = 'out'\n",
"matplotlib.rcParams['ytick.direction'] = 'out'\n",
"\n",
"delta = 0.025\n",
"x = np.arange(-3.0, 3.0, delta)\n",
"y = np.arange(-2.0, 2.0, delta)\n",
"X, Y = np.meshgrid(x, y)\n",
"Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)\n",
"Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)\n",
"# difference of Gaussians\n",
"Z = 10.0 * (Z2 - Z1)\n",
"\n",
"\n",
"# Create a simple contour plot with labels using default colors. The\n",
"# inline argument to clabel will control whether the labels are draw\n",
"# over the line segments of the contour, removing the lines beneath\n",
"# the label\n",
"plt.figure()\n",
"CS = plt.contour(X, Y, Z)\n",
"plt.clabel(CS, inline=1, fontsize=10)\n",
"plt.title('Simplest default with labels')\n",
"\n",
"\n",
"# contour labels can be placed manually by providing list of positions\n",
"# (in data coordinate). See ginput_manual_clabel.py for interactive\n",
"# placement.\n",
"plt.figure()\n",
"CS = plt.contour(X, Y, Z)\n",
"manual_locations = [(-1, -1.4), (-0.62, -0.7), (-2, 0.5), (1.7, 1.2), (2.0, 1.4), (2.4, 1.7)]\n",
"plt.clabel(CS, inline=1, fontsize=10, manual=manual_locations)\n",
"plt.title('labels at selected locations')\n",
"\n",
"\n",
"# You can force all the contours to be the same color.\n",
"plt.figure()\n",
"CS = plt.contour(X, Y, Z, 6,\n",
" colors='k', # negative contours will be dashed by default\n",
" )\n",
"plt.clabel(CS, fontsize=9, inline=1)\n",
"plt.title('Single color - negative contours dashed')\n",
"\n",
"# You can set negative contours to be solid instead of dashed:\n",
"matplotlib.rcParams['contour.negative_linestyle'] = 'solid'\n",
"plt.figure()\n",
"CS = plt.contour(X, Y, Z, 6,\n",
" colors='k', # negative contours will be dashed by default\n",
" )\n",
"plt.clabel(CS, fontsize=9, inline=1)\n",
"plt.title('Single color - negative contours solid')\n",
"\n",
"\n",
"# And you can manually specify the colors of the contour\n",
"plt.figure()\n",
"CS = plt.contour(X, Y, Z, 6,\n",
" linewidths=np.arange(.5, 4, .5),\n",
" colors=('r', 'green', 'blue', (1, 1, 0), '#afeeee', '0.5')\n",
" )\n",
"plt.clabel(CS, fontsize=9, inline=1)\n",
"plt.title('Crazy lines')\n",
"\n",
"\n",
"# Or you can use a colormap to specify the colors; the default\n",
"# colormap will be used for the contour lines\n",
"plt.figure()\n",
"im = plt.imshow(Z, interpolation='bilinear', origin='lower',\n",
" cmap=cm.gray, extent=(-3, 3, -2, 2))\n",
"levels = np.arange(-1.2, 1.6, 0.2)\n",
"CS = plt.contour(Z, levels,\n",
" origin='lower',\n",
" linewidths=2,\n",
" extent=(-3, 3, -2, 2))\n",
"\n",
"# Thicken the zero contour.\n",
"zc = CS.collections[6]\n",
"plt.setp(zc, linewidth=4)\n",
"\n",
"plt.clabel(CS, levels[1::2], # label every second level\n",
" inline=1,\n",
" fmt='%1.1f',\n",
" fontsize=14)\n",
"\n",
"# make a colorbar for the contour lines\n",
"CB = plt.colorbar(CS, shrink=0.8, extend='both')\n",
"\n",
"plt.title('Lines with colorbar')\n",
"#plt.hot() # Now change the colormap for the contour lines and colorbar\n",
"plt.flag()\n",
"\n",
"# We can still add a colorbar for the image, too.\n",
"CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)\n",
"\n",
"# This makes the original colorbar look a bit out of place,\n",
"# so let's improve its position.\n",
"\n",
"l, b, w, h = plt.gca().get_position().bounds\n",
"ll, bb, ww, hh = CB.ax.get_position().bounds\n",
"CB.ax.set_position([ll, b + 0.1*h, ww, h*0.8])\n",
"\n",
"\n",
"plt.show()\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/opt/conda/lib/python3.6/site-packages/ipykernel_launcher.py:20: MatplotlibDeprecationWarning: The bivariate_normal function was deprecated in version 2.2.\n",
"/opt/conda/lib/python3.6/site-packages/ipykernel_launcher.py:21: MatplotlibDeprecationWarning: The bivariate_normal function was deprecated in version 2.2.\n"
]
},
{
"data": {
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 640x480 with 3 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\"\"\"\n",
"Illustrate simple contour plotting, contours on an image with\n",
"a colorbar for the contours, and labelled contours.\n",
"\n",
"See also contour_image.py.\n",
"\"\"\"\n",
"import matplotlib\n",
"import numpy as np\n",
"import matplotlib.cm as cm\n",
"import matplotlib.mlab as mlab\n",
"import matplotlib.pyplot as plt\n",
"\n",
"matplotlib.rcParams['xtick.direction'] = 'out'\n",
"matplotlib.rcParams['ytick.direction'] = 'out'\n",
"\n",
"delta = 0.025\n",
"x = np.arange(-3.0, 3.0, delta)\n",
"y = np.arange(-2.0, 2.0, delta)\n",
"X, Y = np.meshgrid(x, y)\n",
"Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)\n",
"Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)\n",
"# difference of Gaussians\n",
"Z = 10.0 * (Z2 - Z1)\n",
"\n",
"\n",
"# Create a simple contour plot with labels using default colors. The\n",
"# inline argument to clabel will control whether the labels are draw\n",
"# over the line segments of the contour, removing the lines beneath\n",
"# the label\n",
"plt.figure()\n",
"CS = plt.contour(X, Y, Z)\n",
"plt.clabel(CS, inline=1, fontsize=10)\n",
"plt.title('Simplest default with labels')\n",
"\n",
"\n",
"# contour labels can be placed manually by providing list of positions\n",
"# (in data coordinate). See ginput_manual_clabel.py for interactive\n",
"# placement.\n",
"plt.figure()\n",
"CS = plt.contour(X, Y, Z)\n",
"manual_locations = [(-1, -1.4), (-0.62, -0.7), (-2, 0.5), (1.7, 1.2), (2.0, 1.4), (2.4, 1.7)]\n",
"plt.clabel(CS, inline=1, fontsize=10, manual=manual_locations)\n",
"plt.title('labels at selected locations')\n",
"\n",
"\n",
"# You can force all the contours to be the same color.\n",
"plt.figure()\n",
"CS = plt.contour(X, Y, Z, 6,\n",
" colors='k', # negative contours will be dashed by default\n",
" )\n",
"plt.clabel(CS, fontsize=9, inline=1)\n",
"plt.title('Single color - negative contours dashed')\n",
"\n",
"# You can set negative contours to be solid instead of dashed:\n",
"matplotlib.rcParams['contour.negative_linestyle'] = 'solid'\n",
"plt.figure()\n",
"CS = plt.contour(X, Y, Z, 6,\n",
" colors='k', # negative contours will be dashed by default\n",
" )\n",
"plt.clabel(CS, fontsize=9, inline=1)\n",
"plt.title('Single color - negative contours solid')\n",
"\n",
"\n",
"# And you can manually specify the colors of the contour\n",
"plt.figure()\n",
"CS = plt.contour(X, Y, Z, 6,\n",
" linewidths=np.arange(.5, 4, .5),\n",
" colors=('r', 'green', 'blue', (1, 1, 0), '#afeeee', '0.5')\n",
" )\n",
"plt.clabel(CS, fontsize=9, inline=1)\n",
"plt.title('Crazy lines')\n",
"\n",
"\n",
"# Or you can use a colormap to specify the colors; the default\n",
"# colormap will be used for the contour lines\n",
"plt.figure()\n",
"im = plt.imshow(Z, interpolation='bilinear', origin='lower',\n",
" cmap=cm.gray, extent=(-3, 3, -2, 2))\n",
"levels = np.arange(-1.2, 1.6, 0.2)\n",
"CS = plt.contour(Z, levels,\n",
" origin='lower',\n",
" linewidths=2,\n",
" extent=(-3, 3, -2, 2))\n",
"\n",
"# Thicken the zero contour.\n",
"zc = CS.collections[6]\n",
"plt.setp(zc, linewidth=4)\n",
"\n",
"plt.clabel(CS, levels[1::2], # label every second level\n",
" inline=1,\n",
" fmt='%1.1f',\n",
" fontsize=14)\n",
"\n",
"# make a colorbar for the contour lines\n",
"CB = plt.colorbar(CS, shrink=0.8, extend='both')\n",
"\n",
"plt.title('Lines with colorbar')\n",
"#plt.hot() # Now change the colormap for the contour lines and colorbar\n",
"plt.flag()\n",
"\n",
"# We can still add a colorbar for the image, too.\n",
"CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)\n",
"\n",
"# This makes the original colorbar look a bit out of place,\n",
"# so let's improve its position.\n",
"\n",
"l, b, w, h = plt.gca().get_position().bounds\n",
"ll, bb, ww, hh = CB.ax.get_position().bounds\n",
"CB.ax.set_position([ll, b + 0.1*h, ww, h*0.8])\n",
"\n",
"\n",
"plt.show()"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
......
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