How to change the color code in contourf

T
tanvishah · Sep 2, 2020 · 2.1K views
Question
I got an old script and i am modifying it. Below is my script for i=1:2   h= figure;contourf(X',Y',damp_matrix(:,:,i),1000,'EdgeColor','none'); colorbar xlabel ( 'Wind direction [deg]' ); ylabel('Azimuth position [deg]'); end Here Positive values are shown by red and negative values are shown by blue. I need the reverse of this, positive values should show blue contour and negative should show red contour.
Expert Answer
Profile picture of John Williams
John Williams PhD Expert
Answered Aug 20, 2026

At first, you can choose a colormap with the command 'colormap', the default one is 'jet' but you can also use something else like 'hot', e.g. colormap(hot). In your case you need to invert the colormap using 'flipud', you can use the following command: colormap(flipud(jet))

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!