Spectacular Pyplot Contour Colorbar
Matplotlib also offers method which can adjust the existing axes and make room for a colorbar implicitly.
Pyplot contour colorbar. See also the contour image example. Matplotlibpyplotcontourargs dataNone kwargs Parameters. The contour function in pyplot module of matplotlib library is used to plot contours.
Note that if cax is specified it determines the size of the colorbar and shrink and aspect kwargs are ignored. An important use case is the following. Illustrate simple contour plotting contours on an image with a colorbar for the contours and labelled contours.
The matplotlibpyplotcontour are usually useful when Z fX Y ie Z changes as a function of input X and Y. The matplotlibcmScalarMappable ie AxesImage ContourSet etc described by this colorbar. Colorbar kwargs colorbar mappable kwargs colorbar mappable caxcax kwargs colorbar mappable axax kwargs.
This method accept the following parameters that are described below. Matplotlib allows us a large range of Colorbar customization. This parameter is the height values over which the contour is drawn.
In Matplotlib a colorbar is a separate axes that can provide a key for the meaning of colors in a plot. The colorbar function in pyplot module of matplotlib adds a colorbar to a plot indicating the color scale. Pass an integer to draw the colorbar or legend beside a single row or column or pass a tuple to draw it beside a range of rows or columns.
Since the color bar is not part of the contour plot the color bar needs to be applied to the figure object often called fig. Meshgrid x y Z1 np. To display the figure use show method.