Replies: 1 comment 1 reply
-
You want to use matplotlib's import matplotlib.pyplot as plt
import metpy.calc as mpcalc
from metpy.units import units
x = np.linspace(90, 0, 100)
hgt = 3 * (x/90)**2
fig = plt.figure(figsize=(10,8))
ax = plt.subplot(1, 1, 1)
#want the same exact x range
ax.plot(x, hgt)
ax.set_ylabel('Height (m)')
ax.yaxis.label.set_color('tab:blue')
ax.tick_params(axis='y', colors='tab:blue')
ax2 = ax.secondary_yaxis('right', functions=(lambda h: mpcalc.height_to_pressure_std(h * units.km).m,
lambda p: mpcalc.pressure_to_height_std(p * units.hPa).m))
ax2.set_ylabel('Pressure (mb)')
ax2.yaxis.label.set_color('tab:red')
ax2.tick_params(axis='y', colors='tab:red')
ax2.spines['right'].set_color('tab:red')
ax.set_xlabel('Latitude', fontsize=12)
ax.set_title("Height and Pressure of 300k Potential Temperature\n4/21/25 12z\nSouth to North") There's a little more complexity because matplotlib seems to be choking on/dropping the units. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I saw the first attachment in an online module and tried to create it with just 300K potential line. Closest I could get was two lines on the graph. I am looking for help to have just one line of 300K with the two Y axis. Thanks.
Here is my current code
Beta Was this translation helpful? Give feedback.
All reactions