{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Plot 2 contours and remove the last one\nUse :func:`showvar()` to plot the wind as a filled contour plot and the temperature as grey contour lines on the same axes. \n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pylab as pyl\n\nimport pygeode as pyg\nimport numpy as np\nfrom pygeode.tutorial import t2\n\npyl.ioff()\n# Load Temperature and zonal wind\nu = t2.U(time='10 May 2002', pres=(1000,500)).mean(pyg.Lon)\nT = t2.Temp(time='10 May 2002', pres=(1000,500)).mean(pyg.Lon)\n\n# Change vertical axis to log(pressure) with a scale height of 7 km\nu_H = u.replace_axes(pres=u.pres.logPAxis(H=7000)) \nT_H = T.replace_axes(pres=T.pres.logPAxis(H=7000)) \n\nax = pyg.plot.AxesWrapper()\n\npyg.showvar(T_H, clines=10, colors='grey', axes=ax) \nax_wrapper =pyg.showvar(u_H, min=10, cdelt=10, ndiv=3, fig=1, cmap=pyl.cm.BuPu_r, axes=ax) \n\nax.setp(title = 'Plot of temperature and zonal mean wind')\npyl.ion()\nax_wrapper.render()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "``ax_wrapper.axes[0].plots`` contains a list of all the plotted objects\n\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(*ax_wrapper.axes[0].plots, sep=\"\\n\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Remove the temperatue contours from the list and plot the zonal wind contours and colourbar only.\n\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ax_wrapper.axes[0].plots = ax_wrapper.axes[0].plots[1:]\n\nax.setp(title = 'Plot of zonal mean wind')\nax_wrapper.render()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(*ax_wrapper.axes[0].plots, sep=\"\\n\")" ] } ], "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 }