Re: displaying two label bars for two contour plots

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Apr 08 2013 - 09:55:33 MDT

Claudia,

Thanks for providing your script and data offline.

I was able to get the script to work by adding two resource settings. I'm not sure why this is required, however. It appears that NCL wants to put primitives on top of everything, regardless of what order you add them in. The trick seems to be setting various "DrawOrder" resources.

I added the following setting for your "msl_sub" plot:

        res@cnFillDrawOrder = "PreDraw"

This causes the contour fill to be drawn in the "first" phase.

and the following for your polymarkers:

        polyres@tfPolyDrawOrder = "Draw"

This causes the polymarkers to be drawn in the "second" phase, and hence on top of the "first" phase contours.

Finally, it is not necessary to put your gsn_add_polymarker code in loops. You can change every type of code that looks like this:

          points_n1 = new(dim,graphic)

          do j=0,dim-1
            points_n1(j) = gsn_add_polymarker(wks,msl_plot,dum_lon(j),dum_lat(j),polyres)
          end do

to simply this:

            points_n1 = gsn_add_polymarker(wks,msl_plot,dum_lon,dum_lat,polyres)

This change is not necessary, but your code will run a little faster, especially if you are using nested do loops.

--Mary

On Apr 3, 2013, at 6:27 PM, Claudia Walters wrote:

> Mary,
>
> I tried both suggestions, but they didn't work. I was able to get the cloud layer to plot on top of the grid points by using the method described in "draworder_5.ncl", but there "gsn_add_annotation" is used to overlay the two plots and then the size and position of the two plots don't agree. Is there a good way to force the plots into the same size and position?
>
> Thanks,
> Claudia
>
>
>
>
> On Apr 3, 2013, at 4:02 PM, Mary Haley wrote:
>
>> When you create "plot", try setting:
>>
>> res@tfPolyDrawOrder = "Draw" ; Default is "PostDraw"
>>
>> This should force all the gsn_add_polyxxxx stuff to be drawn "earlier", and hence (hopefully) underneath other plot elements.
>>
>> If that doesn't work, try:
>>
>> res@tfPolyDrawOrder = "PreDraw" ; Default is "PostDraw"
>>
>> For more information and examples on drawing order of various plot elements, see:
>>
>> http://www.ncl.ucar.edu/Applications/draworder.shtml
>>
>> --Mary
>>
>> On Apr 3, 2013, at 12:28 PM, Claudia Walters wrote:
>>
>>> Mary,
>>>
>>> ultimately what I am trying to do is plot narr grid points that have LLJs in their vertical speed profile on top of contours of sea-level pressure. On top of that, I would like to show contours of cloudiness. When I use "overlay", my top layer ends up being the grid points rather than contours of cloudiness. Is there any way to get around that?
>>>
>>> I am attaching my full script and a sample map.
>>>
>>> <PastedGraphic-1.tiff>
>>>
>>> <visualization_3.ncl>
>>>
>>> Thanks,
>>> Claudia
>>>
>>>
>>>
>>> On Apr 3, 2013, at 11:53 AM, Mary Haley wrote:
>>>
>>>> Hi Claudia,
>>>>
>>>> If you want to draw one plot on top of another (called an "overlay"), it is better to the "overlay" procedure rather than just drawing the two plots in the same space.
>>>>
>>>> When you use "overlay", the base plot is usually a contour/map plot, and the overlay plot is just a contour or vector plot (you can't overlay a map on a map).
>>>> The overlay plot gets transformed into the data space of the base plot, and actually becomes part of the base plot. In your case, however, since you set tfDoNDCOverlay to True, there won't be any computational transformation, but the two plots will be drawn in the same space, and only the tickmarks from the base plot will be drawn, which is convenient.
>>>>
>>>> So, instead of this code:
>>>>
>>>> plot2 = gsn_csm_contour_map(wks,cloud_sub,res) ; Draw original grid on map
>>>> . . .
>>>> draw(plot1)
>>>> draw(plot2)
>>>>
>>>> try this code:
>>>>
>>>> plot2 = gsn_csm_contour(wks,cloud_sub,res) ; Draw original grid on map
>>>> . . .
>>>> overlay(plot1,plot2)
>>>> draw(plot1)
>>>>
>>>> Also, you don't have to go through the whole effort of turning off tickmarks for plot2. The "overlay" procedure will do this for you.
>>>>
>>>> See example overlay_10.ncl at:
>>>>
>>>> http://www.ncl.ucar.edu/Applications/overlay.shtml#ex10
>>>>
>>>> --Mary
>>>>
>>>> On Apr 3, 2013, at 7:03 AM, Claudia Walters wrote:
>>>>
>>>>> I am trying to show two contour plots in the same map and am having difficulty getting two label bars to show up. I have tried changing the orientation of one to vertical, but then the map area gets resized and doesn't overlay correctly anymore. I have also tried resizing the label bar, so the two label bars would fit side-by-side, but I am having difficulty moving it off-center.
>>>>>
>>>>> Thanks for your help,
>>>>> Claudia
>>>>>
>>>>> <legend_2.ncl>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> ncl-talk mailing list
>>>>> List instructions, subscriber options, unsubscribe:
>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>
>>> Claudia K. Walters, Ph.D.
>>> Assistant Research Scientist
>>> Collegiate Lecturer
>>> Department of Social Sciences
>>> University of Michigan - Dearborn
>>> 4901 Evergreen Road
>>> Dearborn, MI 48128
>>> email: ckwalter@umd.umich.edu
>>> phone: +1.313.593.5636
>>>
>>>
>>>
>>>
>>>
>>
>
> Claudia K. Walters, Ph.D.
> Assistant Research Scientist
> Collegiate Lecturer
> Department of Social Sciences
> University of Michigan - Dearborn
> 4901 Evergreen Road
> Dearborn, MI 48128
> email: ckwalter@umd.umich.edu
> phone: +1.313.593.5636
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Apr 8 09:55:45 2013

This archive was generated by hypermail 2.1.8 : Mon Apr 15 2013 - 20:12:25 MDT