I have some data (a function of two parameters) stored in a matlab format, and I'd like to use matlab to plot it. Once I read the data in, I use mesh()
to make a plot. My mesh()
plot gives me the the value of the function as a color and a surface height, like this:
What matlab plotting function should I use to make a 2D mesh plot where the dependent variable is represented as only a color? I'm looking for something like pm3d map
in gnuplot.
Best Answer
By default
mesh
will color surface values based on the (default)jet
colormap (i.e. hot is higher). You can additionally usesurf
for filled surface patches and set the'EdgeColor'
property to'None'
(so the patch edges are non-visible).2D map: You can get a 2D map by switching the
view
property of the figure... or treating the values in
Z
as a matrix, viewing it as a scaled image usingimagesc
and selecting an appropriate colormap.The color pallet of the map is controlled by
colormap(map)
, wheremap
can be custom or any of the built-in colormaps provided by MATLAB:Update/Refining the map: Several design options on the map (resolution, smoothing, axis etc.) can be controlled by the regular MATLAB options. As @Floris points out, here is a smoothed, equal-axis, no-axis labels maps, adapted to this example: