Re: displaying two label bars for two contour plots

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Sat Apr 06 2013 - 15:01:27 MDT

Claudia,

Using "overlay" is the best way to get the two plots to line up. In addition, when you set tfDoNDCOverlay to True, then it doesn't care if the two plots are not in the same data space. It simply lines up the four corners of the two plots.

For an example, please run the attached script, which uses dummy data. It creates two XY plots which are in completely different data spaces and are different sizes, and then overlays them (THIRD FRAME). By setting res@tfDoNDCOverlay to True, the overlay procedure forces them into the same space, taking on the shape of the first plot passed to "overlay". Try running this script with tfDoNDCOverlay to False, and you will see that the curve from "xy2" disappears.

If overlay not working for you, then mayibe you may just need to change the ordering of the overlays.

If you need further help on this, I will need to see your script and data so I can run it here.

http://www.ncl.ucar.edu/report_bug.shtml#HowToFTP

Thanks,

--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 Sat Apr 6 15:01:38 2013

This archive was generated by hypermail 2.1.8 : Sun Apr 07 2013 - 21:13:30 MDT