.. _sphx_glr_examples_plots_Hodograph_Inset.py: Hodograph Inset =============== Layout a Skew-T plot with a hodograph inset into the plot. .. code-block:: python from datetime import datetime import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1.inset_locator import inset_axes import numpy as np from metpy.io import get_upper_air_data from metpy.io.upperair import UseSampleData from metpy.plots import Hodograph, SkewT .. code-block:: python with UseSampleData(): # Only needed to use our local sample data # Download and parse the data dataset = get_upper_air_data(datetime(1999, 5, 4, 0), 'OUN') p = dataset.variables['pressure'][:] T = dataset.variables['temperature'][:] Td = dataset.variables['dewpoint'][:] u = dataset.variables['u_wind'][:] v = dataset.variables['v_wind'][:] .. code-block:: python # Create a new figure. The dimensions here give a good aspect ratio fig = plt.figure(figsize=(9, 9)) # Grid for plots skew = SkewT(fig, rotation=45) # Plot the data using normal plotting functions, in this case using # log scaling in Y, as dictated by the typical meteorological plot skew.plot(p, T, 'r') skew.plot(p, Td, 'g') skew.plot_barbs(p, u, v) skew.ax.set_ylim(1000, 100) # Add the relevant special lines skew.plot_dry_adiabats() skew.plot_moist_adiabats() skew.plot_mixing_lines() # Good bounds for aspect ratio skew.ax.set_xlim(-50, 60) # Create a hodograph ax_hod = inset_axes(skew.ax, '40%', '40%', loc=1) h = Hodograph(ax_hod, component_range=80.) h.add_grid(increment=20) h.plot_colormapped(u, v, np.hypot(u, v)) # Show the plot plt.show() .. image:: /examples/plots/images/sphx_glr_Hodograph_Inset_001.png :align: center **Total running time of the script:** ( 0 minutes 0.368 seconds) .. container:: sphx-glr-footer .. container:: sphx-glr-download :download:`Download Python source code: Hodograph_Inset.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: Hodograph_Inset.ipynb ` .. rst-class:: sphx-glr-signature `Generated by Sphinx-Gallery `_