[21337] | 1 | Index: ../trunk-jpl/src/m/exp/expdisp.py
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/m/exp/expdisp.py (revision 21277)
|
---|
| 4 | +++ ../trunk-jpl/src/m/exp/expdisp.py (revision 21278)
|
---|
| 5 | @@ -1,5 +1,7 @@
|
---|
| 6 | from expread import expread
|
---|
| 7 | import numpy as np
|
---|
| 8 | +from matplotlib.path import Path
|
---|
| 9 | +import matplotlib.patches as patches
|
---|
| 10 |
|
---|
| 11 | def expdisp(ax,options):
|
---|
| 12 | '''
|
---|
| 13 | @@ -10,29 +12,48 @@
|
---|
| 14 | 'ax' is a handle to the current plot axes, onto which we want to plot
|
---|
| 15 |
|
---|
| 16 | Usage:
|
---|
| 17 | - expdisp(domainoutline,ax)
|
---|
| 18 | + expdisp(ax,options)
|
---|
| 19 |
|
---|
| 20 | - Example:
|
---|
| 21 | - expdisp('domain.exp',plt.gca(),linestyle='--k',linewidth=2,unitmultiplier=1.e3)
|
---|
| 22 | + List of options passable to plotmodel:
|
---|
| 23 | + 'expdisp' : path (or list of paths) to the exp file to be plotted
|
---|
| 24 | + 'explinewidth' : linewidth
|
---|
| 25 | + 'explinestyle' : matplotlib linestyle string
|
---|
| 26 | + 'explinecolor' : matplotlib color string
|
---|
| 27 | + 'expfill' : (True/False) fill a closed contour
|
---|
| 28 | + 'expfillcolor' : Color for a filled contour, only used if expfill is True
|
---|
| 29 | + 'expfillalpha' : alpha transparency for filled contour
|
---|
| 30 | +
|
---|
| 31 | + All options should be passed as lists of length len(number of exp files passed)
|
---|
| 32 | '''
|
---|
| 33 |
|
---|
| 34 | - filename=options.getfieldvalue('expdisp')
|
---|
| 35 | - style=options.getfieldvalue('expstyle','k')
|
---|
| 36 | - linewidth=options.getfieldvalue('explinewidth',1)
|
---|
| 37 | + filenames=options.getfieldvalue('expdisp')
|
---|
| 38 | + linewidth=options.getfieldvalue('explinewidth',[1]*len(filenames))
|
---|
| 39 | + linestyle=options.getfieldvalue('explinestyle',['-']*len(filenames))
|
---|
| 40 | + linecolor=options.getfieldvalue('explinecolor',['k']*len(filenames))
|
---|
| 41 | + fill=options.getfieldvalue('expfill',[0]*len(filenames))
|
---|
| 42 | + alpha=options.getfieldvalue('expfillalpha',[1]*len(filenames))
|
---|
| 43 | + facecolor=options.getfieldvalue('expfillcolor',['r']*len(filenames))
|
---|
| 44 | unitmultiplier=options.getfieldvalue('unit',1)
|
---|
| 45 | - for i in xrange(len(filename)):
|
---|
| 46 | - filenamei=filename[i]
|
---|
| 47 | - stylei=style[i]
|
---|
| 48 | - if type(linewidth)==list:
|
---|
| 49 | - linewidthi=linewidth[i]
|
---|
| 50 | - else:
|
---|
| 51 | - linewidthi=linewidth
|
---|
| 52 | -
|
---|
| 53 | + for i in xrange(len(filenames)):
|
---|
| 54 | + linestylei=linestyle[i]
|
---|
| 55 | + linecolori=linecolor[i]
|
---|
| 56 | + linewidthi=linewidth[i]
|
---|
| 57 | + alphai=alpha[i]
|
---|
| 58 | + facecolori=facecolor[i]
|
---|
| 59 | + filenamei=filenames[i]
|
---|
| 60 | + filli=fill[i]
|
---|
| 61 | domain=expread(filenamei)
|
---|
| 62 | - for i in xrange(len(domain)):
|
---|
| 63 | - if domain[i]['nods']==1:
|
---|
| 64 | - ax.plot(domain[i]['x']*unitmultiplier,domain[i]['y']*unitmultiplier,'o',mec='k',mfc='r',ms=10)
|
---|
| 65 | + for j in xrange(len(domain)):
|
---|
| 66 | + if domain[j]['nods']==1:
|
---|
| 67 | + ax.plot(domain[j]['x']*unitmultiplier,domain[j]['y']*unitmultiplier,'o',mec='k',mfc='r',ms=10)
|
---|
| 68 | + elif filli:
|
---|
| 69 | + verts=np.column_stack((domain[j]['x'],domain[j]['y']))
|
---|
| 70 | + codes=[Path.MOVETO] + [Path.LINETO]*(len(domain[j]['x'])-2) + [Path.CLOSEPOLY]
|
---|
| 71 | + path=Path(verts, codes)
|
---|
| 72 | + patch=patches.PathPatch(path,facecolor=facecolori,edgecolor=linecolori,alpha=alphai,
|
---|
| 73 | + lw=linewidthi)
|
---|
| 74 | + ax.add_patch(patch)
|
---|
| 75 | else:
|
---|
| 76 | - x=domain[i]['x'].tolist() # since expread returns a string representation of the arrays
|
---|
| 77 | - y=domain[i]['y'].tolist()
|
---|
| 78 | - ax.plot(x*unitmultiplier,y*unitmultiplier,stylei,linewidth=linewidthi)
|
---|
| 79 | + x=domain[j]['x'].tolist() # since expread returns a string representation of the arrays
|
---|
| 80 | + y=domain[j]['y'].tolist()
|
---|
| 81 | + ax.plot(x*unitmultiplier,y*unitmultiplier,ls=linestylei,lw=linewidthi,c=linecolori)
|
---|