Changeset 17856
- Timestamp:
- 04/28/14 12:31:00 (11 years ago)
- Location:
- issm/trunk-jpl/src/m/plot
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/plot/applyoptions.py
r17838 r17856 227 227 cb.add_lines(locs,['k' for i in range(len(locs))],npy.ones_like(locs)) 228 228 if options.exist('colorbartitle'): 229 cb.set_label(options.getfieldvalue('colorbartitle'),fontsize=fontsize) 229 if options.exist('colorbartitlepad'): 230 cb.set_label(options.getfieldvalue('colorbartitle'),\ 231 labelpad=options.getfieldvalue('colorbartitlepad'),fontsize=fontsize) 232 else: 233 cb.set_label(options.getfieldvalue('colorbartitle'),fontsize=fontsize) 230 234 cb.ax.tick_params(labelsize=fontsize) 231 235 #}}} … … 235 239 #expdisp 236 240 237 #text 241 #text {{{ 242 if options.exist('text'): 243 text=options.getfieldvalue('text') 244 textx=options.getfieldvalue('textx') 245 texty=options.getfieldvalue('texty') 246 textsize=options.getfieldvalue('textsize') 247 textcolor=options.getfieldvalue('textcolor') 248 textweight=options.getfieldvalue('textweight') 249 textrotation=options.getfieldvalue('textrotation') 250 for label,x,y,size,color,weight,rotation in zip(text,textx,texty,textsize,textcolor,textweight,textrotation): 251 ax.text(x,y,label,transform=ax.transAxes,fontsize=size,color=color,weight=weight,rotation=rotation) 252 #}}} 238 253 239 254 #north arrow -
issm/trunk-jpl/src/m/plot/checkplotoptions.py
r14260 r17856 50 50 #text 51 51 if options.exist('text'): 52 #1: textvalue53 textvalues=options.getfieldvalue('text')54 numtext=len(textvalues)55 52 56 #2: textweight 53 # text values (coerce to list for consistent functionality) 54 textlist=[] 55 text=options.getfieldvalue('text','default text') 56 textlist.extend([text] if isinstance(text,str) else text) 57 numtext=len(textlist) 58 59 # text position 60 textpos=options.getfieldvalue('textposition',[0.5,0.5]) 61 if not isinstance(textpos,list): 62 raise Exception('textposition should be passed as a list') 63 textx=[item[0] for item in textpos] 64 texty=[item[1] for item in textpos] 65 if len(textx)!=numtext or len(texty)!=numtext: 66 raise Exception('textposition should contain one list of x,y vertices for every text instance') 67 68 # font size 69 if options.exist('textsize'): 70 textsize=options.getfieldvalue('textsize',12) 71 sizelist=[] 72 sizelist.extend(textsize if isinstance(textsize,list) else [textsize]) 73 else: 74 sizelist=[12] 75 if len(sizelist)==1: 76 sizelist=npy.tile(sizelist,numtext) 77 78 # font color 79 if options.exist('textcolor'): 80 textcolor=options.getfieldvalue('textcolor','k') 81 colorlist=[] 82 colorlist.extend(textcolor if isinstance(textcolor,list) else [textcolor]) 83 else: 84 colorlist=['k'] 85 if len(colorlist)==1: 86 colorlist=npy.tile(colorlist,numtext) 87 88 # textweight 57 89 if options.exist('textweight'): 58 90 textweightvalues=options.getfieldvalue('textweight') 91 weightlist=[] 92 weightlist.extend(textweight if isinstance(textwieght,list) else [textweight]) 59 93 else: 60 textweightvalues='n' 61 textweightvalues=npy.tile(textweightvalues,numtext) 94 weightlist=['normal'] 95 if len(weightlist)==1: 96 weightlist=npy.tile(weightlist,numtext) 62 97 63 #3 textsize 64 if options.exist('textsize'): 65 textsizevalues=options.getfieldvalue('textsize') 98 # text rotation 99 if options.exist('textrotation'): 100 textrotation=options.getfieldvalue('textrotation',0) 101 rotationlist=[] 102 rotationlist.extend(textrotation if isinstance(textrotation,list) else [textrotation]) 66 103 else: 67 textsizevalues=14 68 textsizevalues=npy.tile(textsizevalues,numtext) 104 rotationlist=[0] 105 if len(rotationlist)==1: 106 rotationlist=npy.tile(rotationlist,numtext) 69 107 70 #4 textcolor 71 if options.exist('textcolor'): 72 textcolorvalues=options.getfieldvalue('textcolor') 73 else: 74 textcolorvalues='k' 75 textcolorvalues=npy.tile(textsizevalues,numtext) 76 77 #5 textposition 78 if options.exist('textposition'): 79 options.getfieldvalue('textposition') 80 else: 81 raise Exception("plotmodel error message: 'textposition' option is missing") 82 83 #6 textrotation 84 if options.exist('textrotation'): 85 textrotationvalues=options.getfieldvalue('textrotation') 86 else: 87 textrotationvalues=0 88 textrotationvalues=npy.tile(textrotationvalues,numtext) 89 90 options.changfieldvalue('text',textvalues) 91 options.changfieldvalue('textsize',textsizevalues) 92 options.changfieldvalue('textweight',textweightvalues) 93 options.changfieldvalue('textcolor',textcolorvalues) 94 options.changfieldvalue('textposition',textpositionvalues) 95 options.changfieldvalue('textrotation',textrotationvalues) 108 options.changefieldvalue('text',textlist) 109 options.addfield('textx',textx) 110 options.addfield('texty',texty) 111 options.changefieldvalue('textsize',sizelist) 112 options.changefieldvalue('textcolor',colorlist) 113 options.changefieldvalue('textweight',weightlist) 114 options.changefieldvalue('textrotation',rotationlist) 96 115 97 116 #expdisp
Note:
See TracChangeset
for help on using the changeset viewer.