import numpy as np
import Ngl

wks = Ngl.open_wks('png', 'lbLabels')

res = Ngl.Resources()
res.sfXArray = np.array([0., 20., 40., 60., 80.])
res.sfYArray = np.array([-60, -20., 20., 60.])
res.cnFillOn = True
res.cnLevelSelectionMode = 'ExplicitLevels'
res.cnLevels = (0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0)
res.lbLabelStrings = ['%2.1f' % l for l in res.cnLevels]

data = np.array([
    [0,1,2,3,4],
    [5,3,2,4,6],
    [6,7,4,3,1],
    [4,2,3,1,0]])
p = Ngl.contour_map(wks, data, res)

Ngl.end()

