Small extension to plot2d

master
Per.Andreas.Brodtkorb 14 years ago
parent 53e054bffe
commit 2a35ffa2b2

@ -341,6 +341,10 @@ class Plotter_2d(Plotter_1d):
def plot2d(wdata, plotflag, *args, **kwds): def plot2d(wdata, plotflag, *args, **kwds):
f = wdata f = wdata
if isinstance(wdata.args, (list, tuple)):
args1 = tuple((wdata.args)) + (wdata.data,) + args
else:
args1 = tuple((wdata.args,)) + (wdata.data,) + args
if plotflag in (1, 6, 7, 8, 9): if plotflag in (1, 6, 7, 8, 9):
PL = 0 PL = 0
if hasattr(f, 'cl') and len(f.cl) > 0: # check if contour levels is submitted if hasattr(f, 'cl') and len(f.cl) > 0: # check if contour levels is submitted
@ -354,7 +358,7 @@ def plot2d(wdata, plotflag, *args, **kwds):
clvec = np.sort(CL) clvec = np.sort(CL)
if plotflag in [1, 8, 9]: if plotflag in [1, 8, 9]:
h = plotbackend.contour(f.args,f.data,levels=CL); h = plotbackend.contour(*args1, levels=CL, **kwds);
#else: #else:
# [cs hcs] = contour3(f.x{:},f.f,CL,sym); # [cs hcs] = contour3(f.x{:},f.f,CL,sym);
@ -363,23 +367,26 @@ def plot2d(wdata, plotflag, *args, **kwds):
if ncl > 12: if ncl > 12:
ncl = 12 ncl = 12
warnings.warn('Only the first 12 levels will be listed in table.') warnings.warn('Only the first 12 levels will be listed in table.')
axcl = cltext(clvec[:ncl], percent=PL) # print contour level text if PL:
clvals, isPL = PL[:ncl], True
else:
clvals, isPL = clvec[:ncl], False
unused_axcl = cltext(clvals, percent=isPL) # print contour level text
elif any(plotflag == [7, 9]): elif any(plotflag == [7, 9]):
pass plotbackend.clabel(h)
#clabel(cs); else:
#else plotbackend.clabel(h)
#clabel(cs,hcs);
elif plotflag == 2: elif plotflag == 2:
h = plotbackend.mesh(f.args,f.data) h = plotbackend.mesh(*args1, **kwds)
elif plotflag == 3: elif plotflag == 3:
h = plotbackend.surf(f.args,f.data); #shading interp % flat, faceted % surfc h = plotbackend.surf(*args1, **kwds) #shading interp % flat, faceted % surfc
elif plotflag == 4: elif plotflag == 4:
h = plotbackend.waterfall(f.args,f.data); h = plotbackend.waterfall(*args1, **kwds)
elif plotflag == 5: elif plotflag == 5:
h =plotbackend.pcolor(f.args,f.data); #%shading interp % flat, faceted h = plotbackend.pcolor(*args1, **kwds) #%shading interp % flat, faceted
elif plotflag == 10: elif plotflag == 10:
h = plotbackend.contourf(f.args,f.f); clabel(cs,hcs); h = plotbackend.contourf(*args1, **kwds)
plotbackend.clabel(h)
plotbackend.colorbar(h) plotbackend.colorbar(h)
else: else:
raise ValueError('unknown option for plotflag') raise ValueError('unknown option for plotflag')

Loading…
Cancel
Save