[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[python #OVP-369800]: skewt plots



Greetings!

1. This one's easy, and thanks for pointing out that we don't actually do this 
in any of our examples (oops, we'll get that fixed). The SkewT object has a 
`.ax` attribute that's is the underlying Matplotlib Axes that you can customize 
to your heart's content. So for the labels, you want to do:


skew.ax.set_ylabel('Pressure (hPa)')
skew.ax.set_xlabel('Temperature (\N{DEGREE CELSIUS})')


That last part uses the Unicode character for the proper symbol for Celsius.

2. There's no easy baked in way yet, though we should when this Pull Request 
finally gets merged (unfortunately it won't be in the next release): 
https://github.com/Unidata/MetPy/pull/2488
For now, you'll need to do it manually using Matplotlib's Axes.text() method, 
like:


import matplotlib.patheffects as mpatheffects
skew.ax.text(0, 600, '7', color='purple',
             path_effects=[mpatheffects.withStroke(foreground='white', 
linewidth=3)])


The "path effects" stuff I do there adds a white outline around the text, 
trying to replicate the sample plot you sent where it looks like there's a 
white box blocking out the lines under the numbers. Another option would be to 
try to use ax.annotate, which has more options for arrows and boxes when 
drawing text like that.

3. We're actually working on adding a height scalebar option for SkewT 
(https://github.com/Unidata/MetPy/issues/262), though even if it existed I'm 
not sure if it could be made to do exactly what you wanted. For now, you can 
use ax.text() MetPy's metpy.calc.pressure_to_height_std() calculation, which 
can give you the height corresponding to a pressure, assuming a standard 
atmosphere.

Cheers!

> I'm trying to create a plot with MetPy (Figure_7.png) that looks like one
> that I created with some old ugly code (
> upperair.SBU_sonde.202202251503.skewT.png).
> 
> I've figured out how to control the colors and thickness of the
> dry_adiabats, etc. but can't find any documentation to help me with a few
> other things.
> 
> 1. I'd like to change the labels of the x and y axes to match the old plot
> (e.g. 'Pressure (hPa)' vs 'hectopascal', etc)
> 2. I'd like to add the labels to the 'special lines' as in the old plot
> (e.g. 0.4, 1, 2, 4, 7, 10, 16 and 8, 12, 16, 20, etc)
> 3. I'd like to add the heights corresponding to the pressure levels just
> inside the y axis as in the old plot.  This will require some computations
> and I might have to write a routine to do that and then use fig.text to add
> them.  Just wondering if there's a built-in way.


Ticket Details
===================
Ticket ID: OVP-369800
Department: Support Python
Priority: Low
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.