爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 5537|回复: 0

xy gsn_create_legend设置位置

[复制链接]

新浪微博达人勋

发表于 2017-1-9 22:40:40 | 显示全部楼层 |阅读模式
NCL
系统平台:
问题截图:
问题概况: 利用gsn_create_legend和gsn_add_annotation 调节lengend的位置,后面一列总是有一点偏差
我看过提问的智慧: 看过
自己思考时长(天): 2

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
opts = xyres
   opts@tiYAxisString = "Surface PM10 (~F33~m~F21~g/m~S~3~N~)"
   wks = gsn_open_wks("png","d04_"+"xy_"+"pm10")
   gsn_define_colormap(wks,"default")
   base = gsn_csm_xy(wks,xtaus,transpose(s_01h_pm10),opts)
   ncol = 3
   nrow = toint(ceil(tofloat(nsite)/ncol))
   print(nrow)
   lgres2 = lgres
   amres2 = amres
   lgres2@vpHeightF     = lgres@vpHeightF*nrow
   print(lgres2@vpHeightF)
   amres2@amOrthogonalPosF = amres@amOrthogonalPosF+lgres2@vpHeightF*1.2
   mkmode2 = array_append_record(mkmode,mkmode,0)
   lnmode2 = array_append_record(lnmode,lnmode,0)
   colors2 = array_append_record(colors,colors,0)
   print(colors)
   print(colors2)

   labels2 = array_append_record(site,site,0)
   colors2(nsite:) = 0
   labels2(nsite:) = ""
   do i = 0, ncol-1
      label = unique_string("label")
      annot = unique_string("annot")
      index = ispan(0,nrow-1,1)+nrow*i
      print(index)
      lgres2@lgMarkerIndexes = mkmode2(index)
      lgres2@lgMarkerColors  = colors2(index)
      lgres2@lgDashIndexes   = lnmode2(index)
      lgres2@lgLineColors    = colors2(index)
      lgres2@lgItemOrder     = ispan(nrow-1,0,1)
      base@$label$ = gsn_create_legend(wks,nrow,labels2(index(::-1)),lgres2)
      base@$annot$ = gsn_add_annotation(base,base@$label$,amres2)
      amres2@amParallelPosF  = amres2@amParallelPosF+lgres2@vpWidthF*1.2
      print(amres2@amParallelPosF)
      print(amres2@amOrthogonalPosF)
   end do
   gsn_panel(wks,base,(/1,1/),plres)
脚本设置


                               
登录/注册后可看大图

对应的print输出
Variable: nrow
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:   [1]
Coordinates:
(0)     15
lgres2@vpHeightF
(0)     0.75


Variable: colors
Type: integer
Total Size: 172 bytes
            43 values
Number of Dimensions: 1
Dimensions and sizes:   [dim0 | 43]
Coordinates:
(0)     2
(1)     3
(2)     4
(3)     5
(4)     6
(5)     7
(6)     8
(7)     9
(8)     10
(9)     11
(10)    12
(11)    13
(12)    14
(13)    15
(14)    16
(15)    17
(16)    18
(17)    19
(18)    20
(19)    21
(20)    22
(21)    23
(22)    24
(23)    25
(24)    26
(25)    27
(26)    28
(27)    29
(28)    30
(29)    31
(30)    32
(31)    33
(32)    34
(33)    35
(34)    36
(35)    37
(36)    38
(37)    39
(38)    40
(39)    41
(40)    42
(41)    43
(42)    44


Variable: colors2
Type: integer
Total Size: 344 bytes
            86 values
Number of Dimensions: 1
Dimensions and sizes:   [dim0 | 86]
Coordinates:
(0)     2
(1)     3
(2)     4
(3)     5
(4)     6
(5)     7
(6)     8
(7)     9
(8)     10
(9)     11
(10)    12
(11)    13
(12)    14
(13)    15
(14)    16
(15)    17
(16)    18
(17)    19
(18)    20
(19)    21
(20)    22
(21)    23
(22)    24
(23)    25
(24)    26
(25)    27
(26)    28
(27)    29
(28)    30
(29)    31
(30)    32
(31)    33
(32)    34
(33)    35
(34)    36
(35)    37
(36)    38
(37)    39
(38)    40
(39)    41
(40)    42
(41)    43
(42)    44
(43)    2
(44)    3
(45)    4
(46)    5
(47)    6
(48)    7
(49)    8
(50)    9
(51)    10
(52)    11
(53)    12
(54)    13
(55)    14
(56)    15
(57)    16
(58)    17
(59)    18
(60)    19
(61)    20
(62)    21
(63)    22
(64)    23
(65)    24
(66)    25
(67)    26
(68)    27
(69)    28
(70)    29
(71)    30
(72)    31
(73)    32
(74)    33
(75)    34
(76)    35
(77)    36
(78)    37
(79)    38
(80)    39
(81)    40
(82)    41
(83)    42
(84)    43
(85)    44


Variable: index
Type: integer
Total Size: 60 bytes
            15 values
Number of Dimensions: 1
Dimensions and sizes:   [15]
Coordinates:
(0)     0
(1)     1
(2)     2
(3)     3
(4)     4
(5)     5
(6)     6
(7)     7
(8)     8
(9)     9
(10)    10
(11)    11
(12)    12
(13)    13
(14)    14
amres2@amParallelPosF
   amres2@amOrthogonalPosF
(0)     -0.03999999
    (0)     1.6


Variable: index
Type: integer
Total Size: 60 bytes
            15 values
Number of Dimensions: 1
Dimensions and sizes:   [15]
Coordinates:
(0)     15
(1)     16
(2)     17
(3)     18
(4)     19
(5)     20
(6)     21
(7)     22
(8)     23
(9)     24
(10)    25
(11)    26
(12)    27
(13)    28
(14)    29
(0)     0.32
(0)     1.6


Variable: index
Type: integer
Total Size: 60 bytes
            15 values
Number of Dimensions: 1
Dimensions and sizes:   [15]
Coordinates:
(0)     30
(1)     31
(2)     32
(3)     33
(4)     34
(5)     35
(6)     36
(7)     37
(8)     38
(9)     39
(10)    40
(11)    41
(12)    42
(13)    43
(14)    44
(0)     0.6800001
(0)     1.6


密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表