Changeset 2603 in lmdz_wrf
- Timestamp:
- Jun 14, 2019, 5:37:52 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing_tools.py
r2600 r2603 14449 14449 return mapv 14450 14450 14451 def drawpolygon_map(vertices, mape, polylab , Nint, linev):14451 def drawpolygon_map(vertices, mape, polylabv, Nint, linev): 14452 14452 """ Function to plot a polygon into a map 14453 14453 vertices: Matrix of vertices of the polygon [[lon1,lat1], ..., [lonM,latM]] 14454 14454 mape: basemap map environtment where to draw the polygon 14455 polylab: label of the polygon (already LaTeX freindly) 14455 polylabv: [polylab, color, size, face, angle, pos]: values for the label of 14456 the polygon 14457 polylab: label of the polygon (already LaTeX freindly, None for no label) 14458 color: color of the characters 14459 size: size of the font 14460 face: weight of the letters 14461 'normal': normal face 14462 'bold': bold face 14463 angle: angle of roation 14464 pos: position as: 14465 'c': center 14466 'vert',Nvert: at coordinates of vertex number Nvert 14467 'overt',xoffset,yoffset: at coordinates of vertex number Nvert aplying an 14468 offset at each direction 14456 14469 Nint: number of intermediate grid points to use in order to have lon, lat 14457 14470 following polygon borders … … 14459 14472 """ 14460 14473 fname = 'drawpolygon_map' 14474 availpolylabpos = ['c', "'vert',Nvert", "'osw',xoffset,yoffset"] 14461 14475 14462 14476 Lvert = vertices.shape[0] … … 14480 14494 if iv == 0 and ij == 0: 14481 14495 plt.plot([pptii[ij],pptii[ij+1]],[pptjj[ij],pptjj[ij+1]], linev[2], \ 14482 color=linev[0], linewidth=linev[1], label=polylab )14496 color=linev[0], linewidth=linev[1], label=polylabv[0]) 14483 14497 else: 14484 14498 plt.plot([pptii[ij],pptii[ij+1]],[pptjj[ij],pptjj[ij+1]], linev[2], \ … … 14503 14517 color=linev[0], linewidth=linev[1]) 14504 14518 14519 # Label location 14520 polylab = polylabv[0] 14521 if polylab is not None: 14522 polylabpos = polylabv[5].split(',') 14523 if polylabpos[0] == 'c': 14524 xlabp = np.sum(vertices[:,0]) 14525 ylabp = np.sum(vertices[:,1]) 14526 elif polylabpos[0] == 'vert': 14527 iv = int(polylabpos[1]) 14528 if iv > Lvert: 14529 print errormsg 14530 print ' ' + fname + ": provided vertex ", iv, 'is too large for ' + \ 14531 'polygon with ', Lvert, 'vertices !!' 14532 quit(-1) 14533 xlabp = vertices[iv,0] 14534 ylabp = vertices[iv,1] 14535 elif polylabpos[0] == 'overt': 14536 iv = int(polylabpos[1]) 14537 if iv > Lvert: 14538 print errormsg 14539 print ' ' + fname + ": provided vertex ", iv, 'is too large for ' + \ 14540 'polygon with ', Lvert, 'vertices !!' 14541 quit(-1) 14542 xlabp = vertices[iv,0] + np.float(polylabpos[2]) 14543 ylabp = vertices[iv,1] + np.float(polylabpos[3]) 14544 else: 14545 print errormsg 14546 print ' ' + fname + ": position of the label '" + polylabpos[0] + \ 14547 "' not available !!" 14548 print ' available ones:', availpolylabpos 14549 quit(-1) 14550 14551 if polylabv[3] == 'normal': 14552 plt.annotate(polylab, xy=(xlabp,ylabp), xycoords='data', \ 14553 color=polylabv[1], fontsize=polylabv[2], rotation=polylabv[4]) 14554 else: 14555 plt.annotate(polylab, xy=(xlabp,ylabp), xycoords='data', \ 14556 color=polylabv[1], fontsize=polylabv[2], weight=polylabv[3], \ 14557 rotation=polylabv[4]) 14558 14559 print 'Lluis ' + fname + ': polylab', polylab, 'xy pos', xlabp, ylabp 14560 14505 14561 return
Note: See TracChangeset
for help on using the changeset viewer.