MATLAB: Fill line with colors using the heatmap bluecolorheatmapplotred Hey everyone, I'm currently trying to use the function: plot to create af figure similar to this: Does anyone know how to use the heatmap function with the plot function? Thanks, Eric Best Answer What about pcolor()clc,clearn = 50;x = linspace(-5,5,n);[X,Y] = meshgrid(x);for i = 1:n y = sinc(x(i))+0.5; Y(:,i) = linspace(0,y,n);endZ = Y;h = pcolor(X,Y,Z);% set(h,'edgecolor','none')shading interpcolorbar Related SolutionsMATLAB: How to plot a prism Use surf instead of plot3 if you want solid-appearing sides. Try this: figuresurf([x;x].', [y;y].', [z,zz], 'FaceColor','g')grid on% axis equal% shading('interp')The axis and shading calls are optional. Note that the surf arguments are two-column martices. MATLAB: Overlay curves over heatmap How about the following way?Plot the heatmapAdd axes over the heatmapPlot lines on the axesSet the background color of the axes to 'none'Adjust the axes size to fit to the heatmapThe following is an example.% Sample datacdata = [45 60 32; 43 54 76; 32 94 68; 23 95 58];figureheatmap(cdata)colorbarax = axes;plot(ax,magic(4),'LineWidth',2)ax.Color = 'none';% Maybe it needs some adjustment, like:ax.Position(3) = 0.72;ax.XTick = [];ax.YTick = []; Related QuestionExtract data from heatmapHow to plot a contour map on the surface of a 3-d surfaceSaving heatmaps as image
Best Answer