[ncl-talk] how to plot this triangle grids

Mary Haley haley at ucar.edu
Thu Jul 27 18:27:28 MDT 2017


I agree, this is an interesting plot.

The key thing is that you need to do the following:

   - Use gsn_csm_blank_plot to set up the X and Y axes for whatever limits
   you need

   This will be based on the number of boxes you need to have in the matrix
   in both directions.

   You could set up the axes limits to go from 0 to nxbox-1 in the X
   direction, and 0 to nybox-1 in the Y direction, where "nxbox" will be, say,
   the number of models you have, and "nybox" is the number of variables.


   - For each variable and each model, you need to get the four values for
   each triangle, and color each triangle based on the range it falls in.

   You can use get_color_rgba to pass a color map, a set of numeric levels,
   and a single value, and it will return an RGBA value that represents the
   correct color for that value.


   - You would then use either gsn_polygon or gsn_add_polygon to fill the
   triangle in that color.  I recommend using gsn_add_polygon, so you can
   actually attach it to the plot (in case the plot needs to be resized later
   in a panel or some other reason).


   - Finally, to attach the extra labelbars, you can use
   gsn_create_labelbar and gsn_add_annotation.

I realized all of this sounded a bit daunting, so I created a script using
dummy data, which I've attached.

The scrip creates an nvars x nmodels x nlat x nlon dummy array, and then
takes the min, max, average, and standard deviation for each nlat x nlon
section and used these values to fill in the four triangles in each

This script is somewhat slow in the add_triangles code, and I think this is
partly because of the loop that gets the color value for each data point.
I will see if I can speed this up.


On Wed, Jul 26, 2017 at 10:18 AM, LI Qi <liqi123sh at qq.com> wrote:

> Dear Mary,
> Thanks for the quick reply.
> My friend asked me the question and he would like to use the quadrants to
> represent four seasons.
> I'll forward the example to him.
> It's really interesting, like expanding a dimension on the matrix.
> Thanks again,
> Best,
> Qi
> ------------------ Original ------------------
> *From: * "Mary Haley";<haley at ucar.edu>;
> *Date: * Wed, Jul 26, 2017 11:53 PM
> *To: * "LI Qi"<liqi123sh at qq.com>;
> *Cc: * "ncl-talk"<ncl-talk at ucar.edu>;
> *Subject: * Re: [ncl-talk] how to plot this triangle grids
> Dear Qi,
> We have an example similar to this.  Please see:
> http://www.ncl.ucar.edu/Applications/table.shtml#ex6
> This uses dummy data, but hopefully you can modify this to create four
> triangles per square.
> If you can provide the data, then I can help you come up with a script.
> --Mary
> On Wed, Jul 26, 2017 at 9:29 AM, LI Qi <liqi123sh at qq.com> wrote:
>> Dear NCL,
>> I'd like to ask how to plot the attached fig.
>> It's RMSE, the four quadrants in one grid representing four different
>> reanalysis.
>> Is this plot attributed to triangle mesh or raster fill?
>> Thanks for any light shed on this.
>> Qi
>> The “portrait” diagram of relative spatially averaged RMSEs in the
>> 1981–2000 climatologies of temperature and precipitation indices simulated
>> by the CMIP5 models with respect to the four reanalyses, ERA40 (left
>> triangle), ERA-Interim (upper triangle), NCEP1 (right triangle), and NCEP2
>> (lower triangle). The RMSEs are spatially averaged over global land grid
>> points. The top row indicates the mean relative RMSE across all indices for
>> a particular model and the grey-shaded columns on the right side indicates
>> the standardized median RMSEmedian,std for CMIP3 and CMIP5 (see text for
>> details).
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> 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/20170727/c63de4e8/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 3EE626EE at F9AE537D.D7C07859.jpg
Type: image/jpeg
Size: 474018 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170727/c63de4e8/attachment-0001.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: triangles_in_quadrants.ncl
Type: application/octet-stream
Size: 11172 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170727/c63de4e8/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: triangles.png
Type: image/png
Size: 191983 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170727/c63de4e8/attachment-0001.png 

More information about the ncl-talk mailing list