[ncl-talk] How to change the line thickness of predefined fill patterns

Karin Meier-Fleischer meier-fleischer at dkrz.de
Tue May 14 01:43:20 MDT 2019


Hi Qingyun and Adam,

there is a resource called *gsFillDotSizeF* to change the size of the 
fillpattern dots (index 17) and *gsFillLineThicknessF* for fillpattern 
line to change the thickness of the lines. The following example 
demonstrate how to change the size and thickness.

    wks = gsn_open_wks("x11","plot_change_fillpattern_scale")

    res                       =  True
    res at gsLineColor           = "black"
    res at gsFillColor           = "black"
    res at tiMainString          = "NCL: plot fill pattern"

    txres                     =  True
    txres at txFontHeightF       =  0.012
    txres at txFontThicknessF    =  3.0
    txres at txJust              = "CenterRight"

    x  = (/0.15, 0.85, 0.85, 0.15, 0.15/)
    y  = (/0.025, 0.025, 0.05, 0.05, 0.025/)
    dy = 0.05
    t  = 0.0375

    dot_size  = 0.0001
    fill_line = 1.0

    do i=1,18
       res at gsFillIndex   =  17
       res at gsFillDotSizeF        =  dot_size
       gsn_polyline_ndc(wks, x, y+(i*dy), res)
       gsn_polygon_ndc(wks, x, y+(i*dy), res)
       gsn_text_ndc(wks, "i = "+ (i-1), 0.15-0.02, (i*dy)+t, txres)
       dot_size  = dot_size + 0.0005
    end do

    frame(wks)

    do i=1,18
       res at gsFillIndex   =  9
       res at gsFillLineThicknessF  =  fill_line
       gsn_polyline_ndc(wks, x, y+(i*dy), res)
       gsn_polygon_ndc(wks, x, y+(i*dy), res)
       gsn_text_ndc(wks, "i = "+ (i-1), 0.15-0.02, (i*dy)+t, txres)
       fill_line = fill_line + 0.3
    end do

    frame(wks)

Bye
Karin

Am 13.05.19 um 23:47 schrieb Adam Phillips:
> Hi Qingyun,
> If I understand what you are asking, you would like to change the 
> thickness of the lines of the various fill patterns that you are 
> using. Unfortunately, I do not believe that you can do this in NCL. 
> See this previous ncl-talk reply from a NCL-developer:
> https://www.ncl.ucar.edu/Support/talk_archives/2013/2900.html
> Also, see the original questioner's response to the above on how they 
> got the line thicknesses to change:
> https://www.ncl.ucar.edu/Support/talk_archives/2013/2885.html
>
> Hope that helps!
> Adam
>
>
> On Mon, May 13, 2019 at 2:10 PM Bian Qingyun <bianqy at tea.ac.cn 
> <mailto:bianqy at tea.ac.cn>> wrote:
>
>
>     Hi Adam,
>
>     Thank you for your suggestion! Attached is the figure. Here is my
>     script.
>
>     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>     load "./shapefile_utils.ncl"
>     begin
>
>     ;---read data
>     dir = "../data/"
>     fin = addfile(dir+"data_num_2001.nc
>     <http://data_num_2001.nc>","r") ;---edit
>     lat = fin->lat
>     lon = fin->lonp = 1 - fin->p(0,:,:)
>     R =   fin->p(1,:,:)
>
>     ;---plot
>     type = "x11"    ;----- edit -----
>     wks =
>     gsn_open_wks(type,"png_panel_snowh_trend_vsstation_1980-2009_yearly")
>     gsn_define_colormap(wks,"ncl_default")
>
>     ;---resources for color-filled plot
>     res                     = True
>     res at gsnMaximize <mailto:res at gsnMaximize>       = True          ;
>     maximize size in frame
>     res at gsnDraw <mailto:res at gsnDraw>             = False         ;
>     Don't draw plots
>     res at gsnFrame <mailto:res at gsnFrame>            = False         ;
>     Don't advance frame
>     res at mpFillOn <mailto:res at mpFillOn> = False
>     res at cnFillOn <mailto:res at cnFillOn>            = True          ;
>     Turn on contour fill
>     res at cnLinesOn <mailto:res at cnLinesOn>           = False         ;
>     Turn off contour lines
>     res at cnLevelSelectionMode <mailto:res at cnLevelSelectionMode> =
>     "ExplicitLevels"
>     res at cnLevels <mailto:res at cnLevels> =
>     (/-0.2,-0.1,-0.05,-0.02,0,0.02,0.05,0.1,0.2/)
>     res at cnFillColors <mailto:res at cnFillColors> =
>     (/2,18,50,82,114,141,178,194,226,248/)
>     res at mpMinLonF <mailto:res at mpMinLonF> = 67    ;TP
>     res at mpMaxLonF <mailto:res at mpMaxLonF> = 105
>     res at mpMinLatF <mailto:res at mpMinLatF> = 25
>     res at mpMaxLatF <mailto:res at mpMaxLatF> = 40
>     res at gsnAddCyclic <mailto:res at gsnAddCyclic> = False
>
>     ;---resources for polyline
>     shp_filename = "TibetanPlateau.shp"
>     lnres                  = True
>     lnres at gsLineColor <mailto:lnres at gsLineColor>      = "black"
>     lnres at gsLineThicknessF <mailto:lnres at gsLineThicknessF> = 3.0
>     ;lnres at gsLineDashPattern = 13
>
>     ;-----Open shapefile and read lat/lon values
>     data_mask_0 = shapefile_mask_data(R,shp_filename,True)
>     plot_fill   = gsn_csm_contour_map(wks,data_mask_0,res)  ; Create
>     filled contours
>     line_mask_0 =
>     gsn_add_shapefile_polylines(wks,plot_fill,shp_filename, lnres)
>
>     ;---resources for shaded plot
>     delete(res at cnLevels <mailto:res at cnLevels>)
>     res at cnMonoFillColor <mailto:res at cnMonoFillColor>   = True
>     res at cnLevels <mailto:res at cnLevels> = (/0.05,0.2/)
>     res at cnMonoFillPattern <mailto:res at cnMonoFillPattern> = False     ;
>     Use multiple fill patterns
>     res at cnFillPatterns <mailto:res at cnFillPatterns> = (/1,2,3/) ;fill
>     with horizontal line, vertical line and slash
>
>     *;---change the thickness of the horizontal line, vertical line
>     and slash
>     **res at cnMonoLineThickness* <mailto:res at cnMonoLineThickness>*= True ;
>     **res at cnLineThicknessF* <mailto:res at cnLineThicknessF>*= 4*
>
>     data_mask_1 = shapefile_mask_data(p,shp_filename,True)
>     plot_shade = gsn_csm_contour(wks,data_mask_1,res)  ; Create shaded
>     contours
>     line_mask_1 =
>     gsn_add_shapefile_polylines(wks,plot_shade,shp_filename, lnres)
>
>     ;---Overlay will transform plot_shade into data space of plot_fill
>     overlay(plot_fill,plot_shade)
>
>     ;---This call resizes plot so it fits in frame
>     pres = True
>     maximize_output(wks,pres)
>
>     end
>
>     ;;;;;;;;;;;;;;;;;;;;;;;;;
>
>     I want to make the line thicker in the shaded plot using the
>     following resources, but they didn't work.
>
>     *;---change the thickness of the horizontal line, vertical line
>     and slash
>     **_res at cnMonoLineThickness_* <mailto:res at cnMonoLineThickness>*= True ;
>     **_res at cnLineThicknessF_* <mailto:res at cnLineThicknessF>*= 4*
>
>     I have no idea how to change the line thickness. Any suggestions
>     are appreciated!
>
>     Best,
>
>     Qingyun
>
>
>         -----Original Messages-----
>         *From:*"Adam Phillips" <asphilli at ucar.edu
>         <mailto:asphilli at ucar.edu>>
>         *Sent Time:*2019-05-14 03:24:05 (Tuesday)
>         *To:* "Bian Qingyun" <bianqy at tea.ac.cn <mailto:bianqy at tea.ac.cn>>
>         *Cc:* Ncl-talk <ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>>
>         *Subject:* Re: [ncl-talk] How to change the line thickness of
>         predefined fill patterns
>
>         Hi Qingyun,
>         Can you send along a simplified script and the resulting image
>         to the ncl-talk list so everyone can see the issue? Doing that
>         would make it easier for folks to assist.
>         Adam
>
>         On Sun, May 12, 2019 at 8:05 PM Bian Qingyun <bianqy at tea.ac.cn
>         <mailto:bianqy at tea.ac.cn>> wrote:
>
>
>             Hello,
>
>             I overlay a shaded contour plot on a filled contour plot
>             following overlay_10.ncl from the NCL website.
>
>             Here are the resources for the shaded plot.
>
>             ;---Resources for shaded plot
>
>             res at cnLevels  <mailto:res at cnLevels>  = (/0.05,0.2/)
>             res at cnMonoFillPattern  <mailto:res at cnMonoFillPattern>  = False        ; Use multiple fill patterns
>             res at cnFillPatterns  <mailto:res at cnFillPatterns>  = (/1,2,3/)   ;predefined fill pattern 1, 2 and 3
>             res at cnMonoFillColor  <mailto:res at cnMonoFillColor>    = True         ; Use same color for shading
>             res at lbLabelBarOn  <mailto:res at lbLabelBarOn>  = False
>
>             The question is I want change the line thicknesses of the predefined fill pattern 1, 2 and 3. I add the following resources, but they didn't work.
>
>             res at cnMonoLineThickness  <mailto:res at cnMonoLineThickness>  = True
>             res at cnLineThicknessF  <mailto:res at cnLineThicknessF>  = 6
>
>             Any suggestions are appreciated!
>
>             Best,
>
>             Qingyun
>
>             _______________________________________________
>             ncl-talk mailing list
>             ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
>             List instructions, subscriber options, unsubscribe:
>             http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>         -- 
>         Adam Phillips
>         Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
>         www.cgd.ucar.edu/staff/asphilli/
>         <http://www.cgd.ucar.edu/staff/asphilli/> 303-497-1726
>
>
>     --
>
>     -------------------------------------------------------
>
>     边晴云 中国科学院大气物理研究所
>
>     TEL:18710037107
>
>     ★☆活着,其实就是活一种精神状态~~
>
>
>
> -- 
> Adam Phillips
> Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
> www.cgd.ucar.edu/staff/asphilli/ 
> <http://www.cgd.ucar.edu/staff/asphilli/> 303-497-1726
>
>
> _______________________________________________
> 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/20190514/c9904adc/attachment.html>


More information about the ncl-talk mailing list