=============== Hodograph Inset =============== `Notebook `_ .. code:: ipython3 import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1.inset_locator import inset_axes from metpy.cbook import get_test_data from metpy.calc import get_wind_components from metpy.plots import SkewT, Hodograph from metpy.units import units %matplotlib inline .. code:: ipython3 # Parse the data p, T, Td, direc, spd = np.loadtxt(get_test_data('may3_sounding.txt'), usecols=(0, 2, 3, 6, 7), skiprows=4, unpack=True) .. code:: ipython3 # Add units to the data arrays p = p * units.mbar T = T * units.degC Td = Td * units.degC spd = spd * units.knot direc = direc * units.deg .. code:: ipython3 # Convert wind speed and direction to components u, v = get_wind_components(spd, direc) .. code:: ipython3 # 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, spd) # Show the plot plt.show() .. image:: Hodograph_Inset_files/Hodograph_Inset_4_0.png