[ncl-talk] Panel plots direction (top to bottom first, then left to right)

Kyle Griffin ksgriffin2 at wisc.edu
Wed Aug 6 13:15:23 MDT 2014


Yes, I did make a mistake and wrote it to convert panels into phases, not
the other way around. While this isn't as fancy, the below should work.
Perhaps redundant and less pretty considering the simplicity of the first
method, but I'll still share it to complete the conversation of doing it in
the loop.

Initialize panel_idx = 0 before the loop.

In the loop, include these lines at the end of the loop. The 'if' will
reset for the second column.

panel_idx = panel_idx + 2
if(phase.eq.4)
  panel_idx = 1
end



Phase number:

---1-----5---
---2-----6---
---3-----7---
---4-----8---

Panel number:

---0-----1---
---2-----3---
---4-----5---
---6-----7---

As I see it, your math just needs to yield:

Phase 1 - Panel 0
Phase 2 - Panel 2
Phase 3 - Panel 4
Phase 4 - Panel 6
Phase 5 - Panel 1
Phase 6 - Panel 3
Phase 7 - Panel 5
Phase 8 - Panel 7


Kyle

----------------------------------------
Kyle S. Griffin
Department of Atmospheric and Oceanic Sciences
University of Wisconsin - Madison
Room 1421
1225 W Dayton St, Madison, WI 53706
Email: ksgriffin2 at wisc.edu


On Wed, Aug 6, 2014 at 1:12 PM, WU, Cheuk Kuen <hkson at connect.hku.hk> wrote:

> Oh! Thank you so much! The first way you suggest is really simple but I
> have never thought of it. How stupid I am! (Although I am still a newbie,
> but I have been using
> NCL for about a month.) I will try it when I back to office in the
> morning.
>
> But I don't understand how method 2 works. I used phase 5 as an example.
> The expected panel_idx should be 1, but ((5-1)%2*4)+((5-1)/2) = 0+2 = 2??
> Can you explain the expression a bit? Thanks!
>
> P.S.: I am sorry that I did not reply to ncl-talk in the previous e-mail
> as that is my first time replying a post here. I will remember to do so
> from now. Thanks :)
>
> John
>
>
> On Thu, Aug 7, 2014 at 1:40 AM, Kyle Griffin <ksgriffin2 at wisc.edu> wrote:
>
>> There are a couple ways you can do this in the looping sense. You can
>> re-arrange the plots in the gsn_panel call...
>>
>>
>> gsn_panel(wks,(/plotpanel(0),plotpanel(4),plotpanel(1),plotpanel(5),..../),(/4,2/),pres)
>>
>> Or you could devise a counter that would handle this alternation with a
>> bit of math, and then just assign each plot to the graphics array per its
>> panel index.
>>
>> panel_idx = ((phase-1)%2*4)+((phase-1)/2)
>> plotpanel(panel_idx) = plot
>>
>>
>> P.S. make sure ncl-talk is in your reply-to when you respond (usually a
>> reply-all works just fine), just so everyone can keep up with the
>> conversation and others can help as well.
>>
>>
>> Kyle
>>
>> ----------------------------------------
>> Kyle S. Griffin
>> Department of Atmospheric and Oceanic Sciences
>> University of Wisconsin - Madison
>> Room 1421
>> 1225 W Dayton St, Madison, WI 53706
>> Email: ksgriffin2 at wisc.edu
>>
>>
>> On Wed, Aug 6, 2014 at 12:31 PM, WU, Cheuk Kuen <hkson at connect.hku.hk>
>> wrote:
>>
>>> Thanks. Actually I am using a do loop from phase = 1 to 8 to plot them:
>>>
>>> if phase.eq.1 then
>>> plotpanel = new(8,graphic)
>>> end if
>>> plotpanel(phase-1) = plot  ("plot" is the individual plot within the do
>>> loop and it will be replaced by the plot of the next phase during the loop)
>>>
>>> Therefore I think I can't easily change my code and use the way you
>>> suggested, although your method is really fast and smart. Any opinions?
>>>
>>> John
>>>
>>>
>>> On Thu, Aug 7, 2014 at 1:03 AM, Kyle Griffin <ksgriffin2 at wisc.edu>
>>> wrote:
>>>
>>>> Change the order with which you store the plots in the array that is
>>>> called in gsn_panel.
>>>>
>>>> phases = new(8,graphic)
>>>> phases(0) = phase1plot
>>>> phases(1) = phase5plot
>>>> phases(2) = phase2plot
>>>> phases(3) = phase6plot
>>>> ...and so on for all 8.
>>>>
>>>> You'll also have to re-arrange your text annotations (such as labeling
>>>> each as panel a and b) if you are setting any in the panel resources.
>>>>
>>>>
>>>> Kyle
>>>>
>>>>
>>>> ----------------------------------------
>>>> Kyle S. Griffin
>>>> Department of Atmospheric and Oceanic Sciences
>>>> University of Wisconsin - Madison
>>>> Room 1421
>>>> 1225 W Dayton St, Madison, WI 53706
>>>> Email: ksgriffin2 at wisc.edu
>>>>
>>>>
>>>> On Wed, Aug 6, 2014 at 11:56 AM, WU, Cheuk Kuen <hkson at connect.hku.hk>
>>>> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I am doing an MJO study. I am plotting the mean geopotential height
>>>>> and wind vector anomalies in different phases of MJO. I plotted all the
>>>>> individual plots, and even tried to do a panel plot. However, the finished
>>>>> panel plot draws the individual plots from left to right, top to bottom,
>>>>> like:
>>>>>
>>>>> Phase1 Phase2
>>>>> Phase3 Phase4
>>>>> Phase5 Phase6
>>>>> Phase7 Phase8
>>>>>
>>>>> I want to plot them from top to bottom, left to right, like:
>>>>> Phase1 Phase5
>>>>> Phase2 Phase6
>>>>> Phase3 Phase7
>>>>> Phase4 Phase8
>>>>>
>>>>> However, I cannot find useful information on the Internet. The most
>>>>> relevant one is
>>>>> http://www.ncl.ucar.edu/Applications/Scripts/panel_12.ncl this one. I
>>>>> thought to plot phases1-4 as the first (left) panel, and phases 5-8 as the
>>>>> second (right) panel. But I have the common label bar and title for all 8
>>>>> plots and I don't want them to appear twice, and I want to place them in
>>>>> the center but not only left or right. Is there a convenient way to draw
>>>>> the plots in the way I want, i.e. from top to bottom, left to right with
>>>>> only one common title and label bar in the centre?
>>>>>
>>>>> Regards,
>>>>> John
>>>>>
>>>>> _______________________________________________
>>>>> ncl-talk mailing list
>>>>> List instructions, subscriber options, unsubscribe:
>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140806/6f8c4598/attachment.html 


More information about the ncl-talk mailing list