Re: using "getvalues" on a panel plot

From: Andrea Allan <aallan_at_nyahnyahspammersnyahnyah>
Date: Thu Aug 01 2013 - 10:05:14 MDT

Mary,

This works beautifully. Thank you so much for your help!

Andrea

On Wed, Jul 31, 2013 at 8:38 PM, Mary Haley <haley@ucar.edu> wrote:

> Hi Andrea,
>
> Actually, I forgot that you don't have to use gsn_panel_return. You can
> use gsn_panel, but set the special panel resource "gsnPanelSave" to True.
> That will "save" the sizes used for the plots so that getvalues should give
> you the value you need.
>
> This is the code that you will need for your panel calls:
>
> panel_res = True
> panel_res@gsnMaximize = True
> panel_res@gsnPanelXWhiteSpacePercent = 2.
> panel_res@gsnPanelYWhiteSpacePercent = 2.
> panel_res@gsnPanelCenter = False
> panel_res@gsnPanelLabelBar = True
> panel_res@lbLabelAutoStride = True
> panel_res@pmLabelBarOrthogonalPosF = 0.01
> panel_res@pmLegendHeightF = 0.3
> panel_res@pmLabelBarHeightF = 0.1
> panel_res@pmLabelBarWidthF = 0.3
> panel_res@lbLabelFontHeightF = 0.01
> panel_res@pmLabelBarOrthogonalPosF = 0.01
> panel_res@gsnPanelBottom = 0.05
> panel_res@gsnPanelTop = 0.95
>
> panel_res@txString = "Growing Degree Days (5 ~F34~0~F~C base)"
> panel_res@txFont = 21
> panel_res@txFontHeightF = 0.018
> panel_res@txJust = "CenterLeft"
> panel_res@gsnPanelSave = True
>
> panel_res@gsnDraw = False
> panel_res@gsnFrame = False
> gsn_panel(wks, plot, (/3,2/), panel_res)
>
> getvalues plot(0)
> "vpXF" : xloc
> end getvalues
>
>
> panel_res@gsnDraw = True
> panel_res@gsnFrame = True
> panel_res@txPosXF = xloc
> gsn_panel(wks, plot, (/3,2/), panel_res)
>
> The reason your subtitles are not lined up is because you have a "," in a
> couple of them. The comma becomes the bottommost part of your string, and
> hence that string will look a little higher than the others.
>
> Unfortunately the only way to get around this is to remove the comma, or
> else somehow add a comma to the other strings so they all have the same
> baseline. Or, add any character that has a part of it that falls beow the
> "baseline", like a 'g', 'y', or 'p'.
>
> --Mary
>
> On Jul 31, 2013, at 3:23 PM, Andrea Allan <aallan@coas.oregonstate.edu>
> wrote:
>
> Mary,
>
> Using gsn_panel_return did exactly what I needed, I was able to get the
> correct coordinates; however, I am still unable to place the title
> correctly -- it seems to be centering about that point and using txJust
> isn't working. I'm also running into the problem now of redrawing the plot
> a second time and subsequently creating two files because I'm calling
> gsn_panel twice, as you'll see from my code. I haven't investigated these
> problems too deeply yet, as I wanted to respond to you first. Maybe your
> example can shed some light.
>
> One other question while you're looking at my code: do you know why the
> plot(0) title "CRU TS 2.1" is a smidgeon lower than the rest of the titles?
> They're all created the same way...
>
> I uploaded the netcdf files to your ftp site (under "incoming") and my
> code is attached.
>
> Thanks again,
> Andrea
>
>
>
> On Wed, Jul 31, 2013 at 1:03 PM, Mary Haley <haley@ucar.edu> wrote:
>
>> Hi Andrea,
>>
>> I realized that my previous answer to another paneling question might
>> help here.
>>
>> Instead of using gsn_panel, you can use gsn_panel_return. This is a
>> function that is identical to gsn_panel, except it returns all the plot ids
>> with the new resized values.
>>
>> I think your code might look like this:
>>
>> pids = gsn_panel_return(wks, plot, (/2,2,2/), panel_res)
>>
>> and then to retrieve the top left corner of the top-left plot, you can
>> try:
>>
>> getvalues pids(0)
>> "vpXF" : vpx
>> "vpYF": vpy
>> end get values
>>
>> However, I think I can come up with a better example for you. Would you
>> be able to share your code and data, and I'll create an example?
>>
>> You can use our ftp, and you can send the information to just me if you
>> don't want to post it to ncl-talk:
>>
>> http://www.ncl.ucar.edu/report_bug.shtml#HowToFTP
>>
>> Thanks,
>>
>> --Mary
>>
>>
>> On Jul 30, 2013, at 12:40 PM, Andrea Allan wrote:
>>
>> > Hello,
>> >
>> > I am trying to create a panel plot and want to display a common title
>> that is aligned with the left edge of the panels. I would like to use
>> "getvalues" to automate this process, as the size & location of my panels
>> change with each plot and manually entering the x-position each time gets
>> very tedious.
>> >
>> > A sample of my code is below. When I use "getvalues" on plot(0) -- the
>> top-left plot on the panel, the retrieved vpXF value does not match any of
>> the values displayed from gsnPanelDebug. Can anyone provide some insight
>> on this? Thanks a lot!
>> >
>> >
>> > do n=0,5
>> > res@gsnRightStringFontHeightF = 0.025
>> > res@gsnRightStringOrthogonalPosF = 0.02
>> > res@gsnRightString = rightStrings(n)
>> > res@gsnLeftStringFontHeightF = 0.025
>> > res@gsnLeftStringOrthogonalPosF = 0.01
>> > res@gsnLeftString = leftStrings(n)
>> > plot(n)=gsn_csm_contour_map(wks,data(n,:,:),res)
>> > end do
>> >
>> > getvalues plot(0)
>> > "vpXF" : xloc
>> > "vpYF" : yloc
>> > end getvalues
>> >
>> > panel_res = True
>> > panel_res@gsnPanelDebug = True
>> >
>> >
>> > panel_res@gsnPanelRowSpec = True
>> > panel_res@Maximize = True
>> >
>> >
>> > panel_res@gsnPanelXWhiteSpacePercent = 2.
>> > panel_res@gsnPanelYWhiteSpacePercent = 2.
>> >
>> > panel_res@gsnPanelCenter = False
>> >
>> > panel_res@gsnPanelBottom = 0.05
>> >
>> > panel_res@gsnPanelTop = 0.95
>> >
>> > panel_res@txString = title
>> > panel_res@txFont = 21
>> > panel_res@txFontHeightF = 0.018
>> > panel_res@txPosXF = xloc
>> >
>> > gsn_panel(wks, plot, (/2,2,2/), panel_res)
>> >
>> >
>> > _______________________________________________
>> > ncl-talk mailing list
>> > List instructions, subscriber options, unsubscribe:
>> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
> <aallan_6panel_example_montana.ncl>
>
>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Aug 1 10:06:09 2013

This archive was generated by hypermail 2.1.8 : Wed Aug 07 2013 - 13:59:00 MDT