Creating subplots for radar displays using Plot_ppi_map

274 views
Skip to first unread message

james kim

unread,
Apr 7, 2022, 3:41:02 PM4/7/22
to Py-ART Users
Hello!

I'm having a bit of trouble creating subplots for NEXRAD ppi plots. I followed examples and for some reason the Py-Art plots dont turn into subplots. Is there an easy fix to this?
I plotted two more blank subplots for reference. It should be four plot configuration.

radar = pyart.io.read(localfiles.success[0].filepath)
       
        display = pyart.graph.RadarMapDisplay(radar)
       
        fig = plt.figure(figsize=[16,10])
       
   
        ax = fig.add_subplot(221)
       
        display.plot_ppi_map('reflectivity', 1, vmin=-8, vmax=64, resolution = '110m',\
                 min_lat=wid500.slat[icase]-0.5, max_lat=wid500.slat[icase]+0.5,\
                 min_lon=wid500.slon[icase]-0.5, max_lon=wid500.slon[icase]+0.5,\
                 edges=False,mask_outside = False,cmap = pyart.graph.cm.NWSRef)
       
       

        ax = fig.add_subplot(222)
        #fig = plt.figure(figsize=[16,10],frameon = False)
       
       
        display.plot_ppi_map('velocity', 1, vmin=-30, vmax=30, resolution= '110m',\
                 min_lat=wid500.slat[icase]-0.5, max_lat=wid500.slat[icase]+0.5,\
                 min_lon=wid500.slon[icase]-0.5, max_lon=wid500.slon[icase]+0.5,\
                 edges=False,mask_outside = False,cmap = pyart.graph.cm.NWSRef)
       
       
        ax = fig.add_subplot(224)
       
        ax = fig.add_subplot(223)
Screen Shot 2022-04-07 at 3.36.46 PM.png

sherma...@gmail.com

unread,
Apr 8, 2022, 5:41:46 PM4/8/22
to Py-ART Users
Hello,

Can you try defining the ax parameter in the display.plot_ppi_map call? ax=ax

Zach S.

james kim

unread,
Apr 11, 2022, 10:37:19 AM4/11/22
to Py-ART Users
Thank you for responding. Unfortunately that did not work. Any other ideas?

Maxwell Grover

unread,
Apr 11, 2022, 1:30:26 PM4/11/22
to Py-ART Users
Hello,

Have you looked at this example yet? 


I would suggest numbering your axes separately (ex. ax1, ax2, ...), and specifying which axes to plot your radar on. For example,

ax1 = plt.subplot(221)
display.plot_grid('REF', 1, vmin=vmin, vmax=vmax, ax=ax1, projection=projection, cmap='pyart_HomeyerRainbow')

ax2 = plt.subplot(222)
display.plot_grid('REF', 1, vmin=vminvmax=vmax, ax=ax2, projection=projection, cmap='pyart_HomeyerRainbow')

Thanks,

Max

james kim

unread,
Apr 13, 2022, 11:11:06 AM4/13/22
to Py-ART Users
Hi Max,

Labeling the axes separately didn't work for some reason. Could it have something to do with how I'm plotting? I'm essentially plotting the recorded location(lat,lon) of a tornado and half a degree in each direction, hence the +-0.5.

James

Maxwell Grover

unread,
Apr 14, 2022, 6:36:39 PM4/14/22
to Py-ART Users
Hi James,

I am not exactly sure why changing the plt.subplot() vs. fig.add_subplot() makes a difference, but the following worked for me (essentially naming each axis differently, and changing add_subplot to just plt.subplot()

I also added the projection information.

----------------------------------------------------------------------------------

fig = plt.figure(figsize=[16,10])

ax1 = plt.subplot(221, projection=ccrs.PlateCarree())

display = pyart.graph.RadarMapDisplay(radar)


display.plot_ppi_map('reflectivity',
                     1,
                     vmin=-8,
                     vmax=64,
                     resolution = '110m',
                     projection=ccrs.PlateCarree(),
                     ax=ax1,
                     edges=False,
                     mask_outside=False,
                     cmap=pyart.graph.cm.NWSRef)



ax2 = plt.subplot(222, projection=ccrs.PlateCarree())



display.plot_ppi_map('velocity',
                     1,
                     vmin=-30,
                     vmax=30,
                     resolution= '110m',
                     projection=ccrs.PlateCarree(),
                     ax=ax2,
                     edges=False,
                     mask_outside=False,
                     cmap=pyart.graph.cm.NWSRef
                    )

------------------------------------------------------------------------------

Thanks,

Max

james kim

unread,
Apr 18, 2022, 1:08:32 PM4/18/22
to Py-ART Users
Worked!! Much Appreciated

James

Reply all
Reply to author
Forward
0 new messages