
try:
	import pylab as p
except ImportError:
	print "could not import pylab, matplotlib has not been installed, no plotting capabilities enabled"

def plot_unit(x,y,z,elements,data,is2d,isplanet,datatype,options):
	"""
	PLOT_UNIT - unit plot, display data

		Usage:
			plot_unit(x,y,z,elements,data,is2d,isplanet,datatype,options)

		See also: PLOTMODEL, PLOT_MANAGER
	"""

	#edgecolor
	edgecolor=options.getfieldvalue('edgecolor','None')

	#number of colorlevels for plots
	colorlevels=options.getfieldvalue('colorlevels',256)

	if datatype==1:
		#element plot
		if is2d:
			p.tripcolor(x,y,elements,data,colorlevels)
		else:
			raise ValueError('plot_unit error: 3D element plot not supported yet')
		return

	elif datatype==2:
		#node plot
		if is2d:
			p.tricontourf(x,y,elements,data,colorlevels)
		else:
			raise ValueError('plot_unit error: 3D node plot not supported yet')
		return

	elif datatype==3:
		print 'plot_unit message: quiver plot not implemented yet'
		return

	elif datatype==4:
		#P1 patch plot
		print 'plot_unit message: P1 patch plot not implemented yet'
		return

	elif datatype==5:
		print 'plot_unit message: P0 patch plot not implemented yet'
		return

	else:
		raise ValueError('datatype=%d not supported' % datatype)
