ECCO-GROUP / ECCOv4-py

A Python library with routines that support the loading, analysis, and plotting fields of the ECCO Version 4 Ocean and Sea-Ice State Estimate. The ecco_v4_py library builds on several valuable tools such as xmitgcm, gcm, xarray, and dask.
MIT License
31 stars 31 forks source link

How to get a contour plot of a different field on top of a contourf plot? #148

Closed Shreyas911 closed 6 months ago

Shreyas911 commented 9 months ago

Hello,

I am doing something like this -

P = ecco.plot_proj_to_latlon_grid(ds.XC, ds.YC,
                                      field,
                                      plot_type = 'contourf',
                                      show_colorbar=True, cmap=cmocean.cm.balance, 
                                      cmin = -1, cmax = 1,
                                      user_lon_0 = -150,
                                      dx=2, dy=2, projection_type = 'robin',
                                      less_output = True)

I want to understand how one can introduce a contour plot on top of this of some other field, say field_new. I appreciate any help in this regard!

Thanks, Shreyas

ifenty commented 6 months ago

Hi @Shreyas911 I think you need to get the 'ax' object back from the figure and then use manually add the second contour. Something like this: https://stackoverflow.com/questions/57525830/how-do-i-combine-multiple-contour-plots