max_plan_vert mutiple plots (subplots)

32 views
Skip to first unread message

Sambit Panda

unread,
Jan 25, 2021, 4:29:31 AM1/25/21
to wradlib-users
Hello Everyone!

I am trying to create subplots (2x3 grid) of a sequence of MAX Z plots from the CAPPI data generated using wradlib. Till now, I have been only able to save individual plots using the wradlib.vis.plot_max_plan_vert for each data set. Can someone help me in creating subplots with 6 images in single figure object?

Thanks in advance!

Regards,
Sambit

Jorma Rahu

unread,
Jan 25, 2021, 8:45:41 AM1/25/21
to wradli...@googlegroups.com
Hey Sambit!

You could check out the curvilinear plotting tutorial at https://docs.wradlib.org/en/stable/notebooks/visualisation/wradlib_plot_curvelinear_grids.html#Plotting-on-Grids 
This is directing you to the Plotting on Grids section. And by "Grids", I mean the option for creating the 2x3 subplot grid you were asking for.

The wradlib.vis.plot_max_plan_and_vert function is I think so-called convenience function, doing a lot of things for you, so you don't have to worry about them, including creating matplotlib figure object, that is I assume the problem you might not get the plots easily on the grid.
At the end of the tutorial link, there is an example of MAX plot with AxesDivider method. You could mix it with the Gridspec method and "ax" keyword at wrl.vis.plot_ppi() function as such:

import matplotlib.gridspec as gridspec
gs = gridspec.GridSpec(2, 3, hspace=0.75, wspace=0.4) # You need to play around with the spacings by yourself to get the best result, this is just copy-paste from the tutorial
# Change the order of them, (2, 3) or (3, 2) that fit your needs. I think the order is flipped with the regular subplot ordering from matplotlib add_subplot() function, where first number means the number of columns and second value the number of rows.
# Here it is opposite, first means number of rows, and second number of columns.
# The gs will be 2 by 3 grid object, that you can access as gs[0,0] ..and so on. Check out the tutorial or matplotlib examples for more examples.
# Assign the axes manually, or with loops:
for i in range(2):
    for j in range(3):
        # normal cg plot
        cgax, pm = wrl.vis.plot_ppi(data2, r=d1, az=d2, fig=fig, ax=gs[i,j])  # The "ax" keyword here is to be noticed, where you put the whole plot on grid
       # I continued the exact code here from the tutorial...

Result:
image.png

I know this is not looking the best, but you can go on with the design here yourself. For example the hspace and wspace values at GridSpec function.
By no means is this the only and most efficient solution. Google around for matplotlib options for subplot gridding, you might find something more easy-to-use.
Hope this was something that you were after. 

Best regards
Jorma Rahu                                  




--
You received this message because you are subscribed to the Google Groups "wradlib-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wradlib-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wradlib-users/e1c25216-07e1-4d6d-a352-fbc20fac9e65n%40googlegroups.com.

Kai Muehlbauer

unread,
Jan 25, 2021, 9:15:47 AM1/25/21
to wradli...@googlegroups.com
Great summary, Jorma! There's nothing I could add here.

Cheers,
Kai

Am 25.01.21 um 14:45 schrieb Jorma Rahu:
> image.png
>
> I know this is not looking the best, but you can go on with the design
> here yourself. For example the hspace and wspace values at GridSpec
> function.
> By no means is this the only and most efficient solution. Google around
> for matplotlib options for subplot gridding, you might find something
> more easy-to-use.
> Hope this was something that you were after.
>
> Best regards
> Jorma Rahu
>
>
>
>
> Kontakt Sambit Panda (<pandas...@gmail.com
> <mailto:pandas...@gmail.com>>) kirjutas kuupäeval E, 25. jaanuar
> 2021 kell 11:29:
>
> Hello Everyone!
>
> I am trying to create subplots (2x3 grid) of a sequence of MAX Z
> plots from the CAPPI data generated using wradlib. Till now, I have
> been only able to save individual plots using the
> wradlib.vis.plot_max_plan_vert for each data set. Can someone help
> me in creating subplots with 6 images in single figure object?
>
> Thanks in advance!
>
> Regards,
> Sambit
>
> --
> You received this message because you are subscribed to the Google
> Groups "wradlib-users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to wradlib-user...@googlegroups.com
> <mailto:wradlib-user...@googlegroups.com>.
> <https://groups.google.com/d/msgid/wradlib-users/e1c25216-07e1-4d6d-a352-fbc20fac9e65n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "wradlib-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to wradlib-user...@googlegroups.com
> <mailto:wradlib-user...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/wradlib-users/CAHt8skaoEeraPW1xktvq-Yn%2BhjYBTuLautc5GPK62N_JqmpKeA%40mail.gmail.com
> <https://groups.google.com/d/msgid/wradlib-users/CAHt8skaoEeraPW1xktvq-Yn%2BhjYBTuLautc5GPK62N_JqmpKeA%40mail.gmail.com?utm_medium=email&utm_source=footer>.

--
Kai Muehlbauer
Institute of Geosciences, Meteorology Section, University of Bonn
Auf dem Huegel 20 | +49 228 739083
D-53121 Bonn | kai.mue...@uni-bonn.de

Sambit Panda

unread,
Jan 25, 2021, 3:40:50 PM1/25/21
to wradli...@googlegroups.com
Thanks Jorma for the elaborate example! Will try it out!



To unsubscribe from this group and stop receiving emails from it, send an email to wradlib-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wradlib-users/4de9d826-0903-e144-b06f-7b060a443fbd%40uni-bonn.de.
Reply all
Reply to author
Forward
0 new messages