Search code examples
pythonmetpy

MetPy Skew-T Fiducial Lines and Limits


When making a skew-T chart with MetPy, it can be difficult to see the temperature and dew point traces with the fiducial lines (mixing ratio, moist adiabats, etc.) plotted as well. Is there a method (not seen in the documentation that I see) to fade these into the background (e.g. alpha)?

Also setting the limits seems to behave a bit strangely as we want to set the x-limit on a skewed line. Not really sure that that could be made easier.


Solution

  • So when you create a Skew-T with:

    import matplotlib.pyplot as plt
    from metpy.plots import SkewT
    
    fig = plt.figure()
    skew = SkewT(fig)
    

    You can set the limits just like you would with a standard Matplotlib Axes, by accessing the .ax attribute on the SkewT instance:

    skew.ax.set_ylim(1000, 100)
    skew.ax.set_xlim(-40, 60)
    

    To control the appearance of the special plot lines, just pass keyword arguments like you would when controlling the appearance of any Matplotlib line; for fading the line, you would want to pass the alpha:

    skew.plot_moist_adiabats(color='dark red', alpha=0.2)