{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# multiple contourf plots with colorbar2\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\nimport matplotlib.pyplot as plt\n\nkw = {\"height_ratios\": [1,1],\"width_ratios\":[98,2]}\nfig, ax = plt.subplots(2,2, gridspec_kw=kw,figsize=(4,8))\n\nx = np.linspace(-5,5,1000)\ny = np.linspace(-5,5,1000)\nX,Y = np.meshgrid(x,y)\n\nH = lambda q,p: p**2/2 + np.cos(q)\n\nax[0,0].plot(x, np.sin(x))\nax[0,1].axis('off')\ncf=ax[1,0].contourf(X,Y, H(X,Y), 10, cmap=plt.cm.hot_r)\nfig.colorbar(cf, cax=ax[1,1])\nplt.show()" ] } ], "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.9.12" } }, "nbformat": 4, "nbformat_minor": 0 }