0

I want to plot the time evolution of a process using contourf in Matlab. The problem is at different time steps Matlab finds the maximum and minimum of my data and sets the colors accordingly, so p=1000 in the first plot could be blue and in the next plot could have some other color. Is there any way to make the colors consistent such that each value has a certain color irrespective of maximum and minimum values?

Thanks

Eman
  • 165
  • 1
  • 1
  • 8

1 Answers1

1
h = colorbar
set(h,'YLim',[min(vect) max(vect)])

where vect is the matrix/vector you are plotting, or you can hard code whatever values you want.

You can also try:

set(gca,'CLim',[min(vect) max(vect)])
Adriaan
  • 17,741
  • 7
  • 42
  • 75
  • Thanks for the reply. This command changes the colorbar range but I want to change the color of the contour itself. – Eman Aug 22 '16 at 21:13
  • Using `caxis` function is better than changing `CLim` properties (in some cases, CLim is not applied). Also with caxis, you can freeze the color scaling after the first plot so that each subsequent plot will have the desired beahavior (same value = same color). Now if you want to change the `contourf` color itself, that is another question. – marsei Aug 22 '16 at 22:49