Re: markers on paneled plots

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Mar 14 2014 - 11:41:38 MDT

Hi Mary,

Thanks for providing a script that I could run directly.

The problem is that when you call gsn_add_polymarker, you need to have a unique return value *every* single time you call it.

You almost have this with the "gvdum" variable, but this variable is being reused for subsequent calls, which causes any previous markers that were added to disappear.

You want to make gvdum a large enough array to store the value from every call to gsn_add_polymarker.

I noticed you were calling gsn_add_polymarker 4 times each time through the loop, so instead of:

    gvdum = new(ngv_min,"graphic")

You want:

    gvdum = new((/4,ngv_min/),"graphic") ;

and then, change:

       gvdum(im) = gsn_add_polymarker(wks,plots(0),gv_lon(im),gv_lat(im),gsres)
       gvdum(im) = gsn_add_polymarker(wks,plots(1),gv_lon(im),gv_lat(im),gsres)
       gvdum(im) = gsn_add_polymarker(wks,plots(0),gv_lon(im),gv_lat(im),gsres)
       gvdum(im) = gsn_add_polymarker(wks,plots(1),gv_lon(im),gv_lat(im),gsres

to:

       gvdum(0,im) = gsn_add_polymarker(wks,plots(0),gv_lon(im),gv_lat(im),gsres)
       gvdum(1,im) = gsn_add_polymarker(wks,plots(1),gv_lon(im),gv_lat(im),gsres)
       gvdum(2,im) = gsn_add_polymarker(wks,plots(0),gv_lon(im),gv_lat(im),gsres)
       gvdum(3,im) = gsn_add_polymarker(wks,plots(1),gv_lon(im),gv_lat(im),gsres

You need to do something similar for dc8dum, which is called 2 times.

    dc8dum = new((/2,ndc8_min/),"graphic") ;

       dc8dum(0,im) = gsn_add_polymarker(wks,plots(0),dc8_lon(im),dc8_lat(im),gsres)
       dc8dum(1,im) = gsn_add_polymarker(wks,plots(0),dc8_lon(im),dc8_lat(im),gsres)

If you want to add markers to other plots, make sure you create a new "dum" variable for this.

You can continue to use the same resource list for convenience, but it just depends on
what you want to do.

For example, if you want to add markers to all three plots, and you just need to change the
color and style every time, then sure, use the same "gsres" resource list.

However, if you are planning to drastically change the markers every time, and find yourself
having to change the resources frequently inside the do loop, then it might be more convenient
to create multiple resource lists to hold the values that you want, and then you don't have
to keep changing them in the loop.

For example, you are using "gsres" to do both filled and hollow markers. This is perfectly fine, but
it does require that you reset "gsMarkerIndex", "gsMarkerSizeF" and "gsMarkerColor" inside the do loop.

You could potentially set up two resource lists outside the do loop, one for filled dots and one for hollow dots:

; gsres = True ; Don't need this
    mkres_f = True
    mkres_h = True
    mkres_h@gsMarkerIndex = 4 ; 4=open circle
    mkres_h@gsMarkerThicknessF = 1.0
    mkres_h@gsMarkerColor = "black"
    mkres_h@gsMarkerSizeF = 0.010
    mkres_f@gsMarkerIndex = 16 ; 6=filled dots
    mkres_f@gsMarkerThicknessF = 1.0
    mkres_f@gsMarkerSizeF = 0.008 ; make smaller than hollow dot

And then inside your big do loop, you only need to set mkres_f@gsMarkerColor"

; outline circle in black
       gvdum(0,im) = gsn_add_polymarker(wks,plots(0),gv_lon(im),gv_lat(im),mkres_h)
       gvdum(1,im) = gsn_add_polymarker(wks,plots(1),gv_lon(im),gv_lat(im),mkres_h)

; fill in with color
       mkres_f@gsMarkerColor = colors(imcl)

       gvdum(2,im) = gsn_add_polymarker(wks,plots(0),gv_lon(im),gv_lat(im),mkres_f)
       gvdum(3,im) = gsn_add_polymarker(wks,plots(1),gv_lon(im),gv_lat(im),mkres_f)

--Mary

On Mar 13, 2014, at 5:21 PM, Mary Barth <barthm@ucar.edu> wrote:

> Hi there,
>
> I've been working on a somewhat complicated plot to compare model
> results from two simulations to aircraft observations.
>
> The steps of the script are to
> 1. read aircraft data -- I use ncl/6.2.0 to read icartt files
> 2. read model results from two simulations
> 3. contour and plot model results
> 4. add polymarkers of aircraft data
> 5. panel the two plots
> 6. calculate difference of two model simulations
> 7. add difference plot as 3rd plot of frame
>
> In the past, I have successfully plotted aircraft data onto model
> results for a single plot (e.g.
> /glade/p/mmm/barthm/NCL/DC3/CO_1.5km_obs_05-29_YSUctrl.ps ) and I like
> the result.
>
> For the panel plot, I followed
> https://www.ncl.ucar.edu/Applications/Scripts/polyg_9.ncl as an example.
>
> It's important for my markers to have both a color fill and a black
> outline of the markers (as shown in CO_1.5km_obs_05-29_YSUctrl.ps). So,
> I plot first MarkerStyle=16 and vary the color and then MarkerStyle=4.
> like is done in newcolor_4.ncl . For the panel plot, I get only the open
> circles plotted (i.e. the second gsn_add_polymarker call).
>
> How can I get both color fill and open circles onto the paneled plot?
>
> I would also like to get the aircraft data on both the first two plots.
> Can I simply add a gsn_add_polymarker call pointing to the second plot,
> or do I need to use different resources, or put in another loop?
>
> My script is: /glade/p/mmm/barthm/NCL/DC3/var_compare2sims_obs.ncl
>
> and the current output is: VARgas_ctrl_aqmeii_05-29.ps in the same directory
>
> Thanks for any help,
> Mary
>
> --
> ^--^--^--^--^--^--^--^--^--^--^--^--^--^--^--^--^--^--^--^--^
> Mary Barth Phone: 303-497-8186
> NCAR Earth System Laboratory FAX: 303-497-1400
>
> P.O. Box 3000
>
> Boulder, CO 80307 email: barthm@ucar.edu
>
> http://www.mmm.ucar.edu/people/barth/
> +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
> _______________________________________________
> 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 Fri Mar 14 11:41:52 2014

This archive was generated by hypermail 2.1.8 : Fri Mar 14 2014 - 15:08:52 MDT