.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/plots/Skew-T_Layout.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_plots_Skew-T_Layout.py: ========================== Skew-T with Complex Layout ========================== Combine a Skew-T and a hodograph using Matplotlib's `GridSpec` layout capability. .. GENERATED FROM PYTHON SOURCE LINES 11-21 .. code-block:: Python import matplotlib.gridspec as gridspec import matplotlib.pyplot as plt import pandas as pd import metpy.calc as mpcalc from metpy.cbook import get_test_data from metpy.plots import add_metpy_logo, Hodograph, SkewT from metpy.units import units .. GENERATED FROM PYTHON SOURCE LINES 22-24 Upper air data can be obtained using the siphon package, but for this example we will use some of MetPy's sample data. .. GENERATED FROM PYTHON SOURCE LINES 24-34 .. code-block:: Python col_names = ['pressure', 'height', 'temperature', 'dewpoint', 'direction', 'speed'] df = pd.read_fwf(get_test_data('may4_sounding.txt', as_file_obj=False), skiprows=5, usecols=[0, 1, 2, 3, 6, 7], names=col_names) # Drop any rows with all NaN values for T, Td, winds df = df.dropna(subset=('temperature', 'dewpoint', 'direction', 'speed' ), how='all').reset_index(drop=True) .. GENERATED FROM PYTHON SOURCE LINES 35-37 We will pull the data out of the example dataset into individual variables and assign units. .. GENERATED FROM PYTHON SOURCE LINES 37-45 .. code-block:: Python p = df['pressure'].values * units.hPa T = df['temperature'].values * units.degC Td = df['dewpoint'].values * units.degC wind_speed = df['speed'].values * units.knots wind_dir = df['direction'].values * units.degrees u, v = mpcalc.wind_components(wind_speed, wind_dir) .. GENERATED FROM PYTHON SOURCE LINES 46-78 .. code-block:: Python # Create a new figure. The dimensions here give a good aspect ratio fig = plt.figure(figsize=(9, 9)) add_metpy_logo(fig, 630, 80, size='large') # Grid for plots gs = gridspec.GridSpec(3, 3) skew = SkewT(fig, rotation=45, subplot=gs[:, :2]) # 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(-30, 40) # Create a hodograph ax = fig.add_subplot(gs[0, -1]) h = Hodograph(ax, component_range=60.) h.add_grid(increment=20) h.plot(u, v) # Show the plot plt.show() .. image-sg:: /examples/plots/images/sphx_glr_Skew-T_Layout_001.png :alt: Skew T Layout :srcset: /examples/plots/images/sphx_glr_Skew-T_Layout_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.202 seconds) .. _sphx_glr_download_examples_plots_Skew-T_Layout.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Skew-T_Layout.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Skew-T_Layout.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_