import vtk
s = vtk.vtkSphereSource()
f = vtk.vtkElevationFilter()
f.SetInput(s.GetOutput())
f.Update()
rng = f.GetOutput().GetPointData().GetScalars().GetRange()
m = vtk.vtkPolyDataMapper()
m.SetInput(f.GetOutput())
m.SetScalarRange(rng)

a = vtk.vtkActor()
a.SetMapper(m)

sb = vtk.vtkScalarBarActor()
sb.SetTitle("Elevation")
# If the orientation is horizontal there is a problem.
sb.SetOrientationToHorizontal()
# Vertical is OK.
#sb.SetOrientationToVertical()
sb.SetWidth(0.8)
sb.SetHeight(0.17)
sb.SetPosition(0.1, 0.05)
sb.SetLookupTable(m.GetLookupTable())

ren = vtk.vtkRenderer()
ren.AddActor(a)
rw = vtk.vtkRenderWindow()
rw.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(rw)

sbw = vtk.vtkScalarBarWidget()
sbw.SetInteractor(iren)
sbw.SetScalarBarActor(sb)
sbw.On()

iren.Initialize()
iren.Start()

