MATLAB: Why ‘colormap’ did not change the color of the plots colorcolormapmatlab colorplots example: figure, plot(rand(5))colormap hot above code did not change the color of plot. Best Answer If you want to change the color of the lines based on a colormap, you can apply those colors to the "ColorOrder" property of the axes. figureh = plot(rand(5));% Create a colormap based on the number of lines in your plotcmap = hot(numel(h)); %you can use any colormap here% Apply the colors to the linesset(gca, 'ColorOrder', cmap)Alternatively, you can apply the colors to the color handles of line objects, set(h,{'Color'}, mat2cell(cmap,ones(numel(h),1),3))Note that if your really want to use "hot", you'll end up with yellow and white lines wich are difficult or impossible to see against the default white axis. In that case you can change the axis colors to some other dark color. set(gca, 'Color', [.2 .2 .2]) Related SolutionsMATLAB: How to change the colors in colormap function You can try one of the many built-in colormaps such as hsv, jet, parula, etc.cmap = jet(256);colormap(cmap);colorbar; MATLAB: Pick random colors from a color map Try this:% Define the two colormaps.cmap1 = hot(15)cmap2 = winter(15) % Combine them into one tall colormap.combinedColorMap = [cmap1; cmap2]% Pick 15 rows at random.randomRows = randi(size(combinedColorMap, 1), [15, 1])% Extract the rows from the combined color map.randomColors = combinedColorMap(randomRows, :) Related QuestionCreate plot with multiple overlayed lines, where colorbar corresponds to color of line
Best Answer