Contour plot color matlab11/22/2023 A contour object in Maltab circa 2010 was a combination of some lines (the contour lines) and some patches (the shaded regions), and my function just looped over those patches and assigned new colors to their CData properties. At that time, it was just a wrapper around contourf. This function began its life as a very simple function back in 2010. Hc = contourfcmap( x, y, z, clev, jet( 12). Without labeling the contour lines, it's difficult to tell which values in the colorbar correspond to the color intervals in the contourf plot. Examplesįirst we'll plot a contourf plot using the standard Matlab functions. H = contourfcmap(.) returns a structure h whose fields hold the colorbar axis handle structure ( h.cb, see pcolorbar.m for details), contour object ( h.h), contour matrix ( h.c), and patch object ( h.p). Default is no colorbar.Ĭontourfcmap(x,y,z,clev,cmap, 'evencb', evencb) indicates whether to space the colors on the colorbar evenly (evencb = true) or to size them according to the clev values (evencb = false). Default is 'recolor' (though I now recommend 'calccontour' for R2017b or later).Ĭontourfcmap(x,y,z,clev,cmap, 'cbarloc', cbarloc) adds a psuedo-colorbar using the colorbar location indicator cbarloc. Default is white.Ĭontourfcmap(x,y,z,clev,cmap, 'method', method) allows you to switch between the 'recolor' and 'calccontour' algorithms (see below for details). Default is white.Ĭontourfcmap(x,y,z,clev,cmap, 'hi', hi) indicates the color value hi (a 1 x 3 RGB array) to be used for any region with data higher than the last contour level. clev is an n x 1 vector defining the contour line levels, and cmap is an n-1 x 1 colormap array defining the colors to be used between each of the contour levels.Ĭontourfcmap(x,y,z,clev,cmap, 'lo', lo) indicates the color value lo (a 1 x 3 RGB array) to be used for any region with data lower than the first contour level. z must be at least a 2x2 matrix x and y can either be matrices defining the grid for z, or vectors that correspond to the column and row coordinates, respectively. The following folders need to be added to your Matlab Search path (via addpath, pathtool, etc.):Ĭontourfcmap( x, y, z, clev, cmap, Name, Value)Ĭontourfcmap(x,y,z,clev,cmap) plots a filled contour plot of the matrix z with coordinates x and y. The File Exchange entry is updated daily from the GitHub repository. This code can be downloaded from Github or the MatlabCentral File Exchange. This function requires Matlab R14 or later. This function instead allows the user to specify exactly which colors to use in each interval, and also to choose colors for regions that exceed the contour line limits. exactly which color corresponds to each contour interval), can often be confusing and inconsistent. However, the relationship between a contourf plot and its colormap (i.e. This function creates a shaded contour map, similar to that created by the contourf function. This repository includes the code for the contourfcmap.m Matlab function, along with all dependent functions required to run it. Contourfcmap.m: filled contour plot with precise colormap
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |