Saturday 15 June 2013

python - Raster to Numpy Array - how to change a default color-scheme of a matplotlib plot -



python - Raster to Numpy Array - how to change a default color-scheme of a matplotlib plot -

i trying alter default color scheme of matplotlib plot.

so far have next code:

import arcpy import matplotlib.pyplot plt import matplotlib.cm input_raster = arcpy.raster( 'g:\\wetnessindex' ) arr = arcpy.rastertonumpyarray( input_raster ) cm = plt.set_cmap( 'blues' ) plt.imshow( arr ) plt.title( 'wetness index' ) plt.colorbar( orientation = 'vertical' ) plt.show()

the line cm = plt.get_cmap( 'blues' ) doesn't seem create difference thought would, based on matplotlib color_maps reference.

you need pass colour scheme want argument imshow.

e.g.

im = plt.imshow(arr,cmap="hot")

or in case:

plt.imshow(arr,cmap=cm)

alternatively, can utilize set_cmap command set default cmap current figure:

plt.set_cmap('hot') plt.imshow(arr)

python python-2.7 numpy matplotlib arcpy

No comments:

Post a Comment