示例#1
0
patches = []
data = []
for iCell in range(nCells):
    if  latCell[iCell] >= mapBottom and \
        latCell[iCell] <= mapTop    and \
        lonCell[iCell] >= mapLeft   and \
        lonCell[iCell] <= mapRight:
        xypoly = np.empty((nEdgesOnCell[iCell], 2), np.float)
        for i in range(nEdgesOnCell[iCell]):
            xypoly[i, 0] = lonVertex[verticesOnCell[iCell, i] - 1]
            xypoly[i, 1] = latVertex[verticesOnCell[iCell, i] - 1]
        polygon = Polygon(xypoly, closed=True)
        patches.append(polygon)
        data.append(datin[iCell])

print len(patches), ' patches'
p = PatchCollection(patches, cmap=matplotlib.cm.hot_r, edgecolors='none')
data = np.array(data)
p.set_array(data)
p.set_clim(vmin=vmin, vmax=vmax)
p.set_clip_on(True)
ax.add_collection(p)
plt.xlim(mapLeft, mapRight)
plt.ylim(mapBottom, mapTop)
plt.grid(True)
plt.colorbar(p)
plt.title('MPAS cell-fill orography')
plt.tight_layout()

plt.show()
示例#2
0
plt.show()


# 2 rectangle
import matplotlib.pyplot as plt

# Build a rectangle in axes coords
left, width = .25, .5
bottom, height = .25, .5
right = left + width
top = bottom + height
ax = plt.gca()
p = plt.Rectangle((left, bottom), width, height, fill=False)
p.set_transform(ax.transAxes)
p.set_clip_on(False)
ax.add_patch(p)


ax.text(left, bottom, 'left top',
        horizontalalignment='left',
        verticalalignment='top',
        transform=ax.transAxes)

ax.text(left, bottom, 'left bottom',
        horizontalalignment='left',
        verticalalignment='bottom',
        transform=ax.transAxes)

ax.text(right, top, 'right bottom',
        horizontalalignment='right',