Non-uniform contourf/imagesc/colorbar
Nota del editor: This file was selected as MATLAB Central Pick of the Week
The colormap in Matlab supports only linear mapping, which is inconvenient when plotting data spaning multiple orders, e.g., peaks(100).^4. This function uses the trick of piecewise-linearly mapping to allow non-uniform contour levels contourf/imagesc/pcolor.
--- Usage ---
varargout = contourfnu(x,y,data,v,cmap,pos_colorbar,overticklabel,method,ninterp,nancolor)
--- Input Variables ---
x : x-coordinates of grid, vector or 2d matrix
y : y-coordinates of grid, vector or 2d matrix
If x and y are vectors, then length(x)==size(z,2) and length(y)==size(Z,1).
If x and y are 2d matrix, they are generated by meshgrid
data : 2d matrix to be ploted
(Optional:)
v : vector of contour levels (default:linspace(datamin,datamax,10))
cmap : color map array (default:jet)
pos_colorbar : 'none', or location with respect to the axes (default:'eastoutside')
overticklabel : whether or not label the overrange ticks at colorbar (default:true)
method : imagesc, contourf, contour or pcolor (default:imagesc)
ninterp : repeatedly interp times in each dimension (default:0)
nancolor : axis backgroud color
--- Output Variable ---
hout : structure with handles
.h plot handle
.c contour matrix (method='contourf')
.hc colorbar handle (pos_colorbar~='none')
Citar como
Yuxin Jiang (2024). Non-uniform contourf/imagesc/colorbar (https://www.mathworks.com/matlabcentral/fileexchange/65424-non-uniform-contourf-imagesc-colorbar), MATLAB Central File Exchange. Recuperado .
Compatibilidad con la versión de MATLAB
Compatibilidad con las plataformas
Windows macOS LinuxCategorías
- MATLAB > Graphics > 2-D and 3-D Plots > Contour Plots >
Etiquetas
Agradecimientos
Inspirado por: contourfcmap: filled contour plot with precise colormap
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Descubra Live Editor
Cree scripts con código, salida y texto formateado en un documento ejecutable.
contourfnu
Versión | Publicado | Notas de la versión | |
---|---|---|---|
1.5.0.0 | Add support for pcolor |
||
1.4.0.0 | Update demo and description.
|
||
1.3.0.0 | handle Inf(s) |
||
1.2.0.0 | handle NaNs |
||
1.1.0.0 | add a parameter to control the max/min ticklabel(s)
|
||
1.0.0.0 | update description |