Including this before the savefig call produces this plot (made using 11x11 grid for clarity): Setting the grid color to 'white' works well with the colors used by the colormap (ie the default black does not show up well). To add a grid, as shown in this example, use the grid method. Img2 = pyplot.imshow(zvals,interpolation='nearest', If you want a gradient and not a discrete color map, make a color map by linearly interpolating through a series of colors: fig = pyplot.figure(2)Ĭmap2 = _list('my_colormap', The alternative is to set origin="lower", so that first point is plotted in the lower left corner. The default is 'upper left', which is why in my posted plot the y axis has 0 in the upper left and 99 (not shown) in the lower left. You should note, that imshow accepts the origin keyword, which sets the where the first point is assigned. ![]() It explains that the number of boundaries need to be one larger then then number of colors. ![]() The details for the color bar setup were taken from a matplotlib example: colorbar_only.py. Img = pyplot.imshow(zvals,interpolation='nearest', ![]() # tell imshow about color map so that only set colors are used # make values from -5 to 5, for this exampleĬmap = () Matplotlib has the imshow method for plotting arrays: import matplotlib as mpl
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |