source: issm/trunk/src/m/plot/plot_vertexnumbering.py@ 24313

Last change on this file since 24313 was 24313, checked in by Mathieu Morlighem, 5 years ago

merged trunk-jpl and trunk for revision 24310

File size: 1.7 KB
Line 
1import numpy as np
2from processmesh import processmesh
3from applyoptions import applyoptions
4
5
6def plot_vertexnumbering(md, options, fig, axgrid, gridindex):
7 '''
8 PLOT_VERTEXNUMBERING - plot vertex numbering
9
10 Usage:
11 plot_vertexnumbering(md, options, fig, axes)
12
13 See also: PLOTMODEL
14
15 '''
16 #process data and model
17 x, y, z, elements, is2d, isplanet = processmesh(md, [], options)
18
19 ax = axgrid[gridindex]
20 fig.delaxes(axgrid.cbar_axes[gridindex])
21
22 if is2d:
23 ax.triplot(x, y, elements)
24 else:
25 print('Not Implemented Yet')
26
27 XPad = 0.1 * (np.nanmax(x) - np.nanmin(x))
28 YPad = 0.1 * (np.nanmax(y) - np.nanmin(y))
29 #plot mesh
30 ax.triplot(x, y, elements)
31 ax.set_xlim((np.min(x) - XPad, np.max(x) + XPad))
32 ax.set_ylim((np.min(y) - YPad, np.max(y) + YPad))
33
34 highlightpos = options.getfieldvalue('highlight', [])
35 if highlightpos != 'none':
36 #if just one element duplicate it to avoid coloring issues
37 if type(highlightpos) == int:
38 highlightpos = [highlightpos, highlightpos]
39 #convert from to matlab numbering
40 highlightpos = [pos - 1 for pos in highlightpos]
41
42 # and numbers
43 for i, Xcoord in enumerate(x):
44 if i in highlightpos:
45 props = dict(boxstyle='circle', pad=0.1, color='r')
46 else:
47 props = dict(boxstyle='circle', pad=0.1, color='w')
48 ax.text(x[i], y[i], str(i + 1), ha='center', va='center', backgroundcolor='w', clip_on=True, bbox=props)
49
50 #apply options
51 options.addfielddefault('title', 'Vertex numbers (matlab indexation)')
52 options.addfielddefault('colorbar', 'off')
53 applyoptions(md, [], options, fig, axgrid, gridindex)
Note: See TracBrowser for help on using the repository browser.