specific color in contourf

조회 수: 3 (최근 30일)
Hail
Hail 2015년 4월 28일
답변: Star Strider 2015년 4월 28일
I have a contourf plot. I want to designate a certain value to be a certain color. For example I want all z=0 value to be colored red. How do I accomplish this?

채택된 답변

Star Strider
Star Strider 2015년 4월 28일
You can choose amongst several colormap options, although not knowing your data range, I can’t suggest anything specific. There are several related topics in the documentation that apply, specifically Change Fill Colors for Contour Plot and several others, most notably colormap, that page links to.
Since a colormap is an (Nx3) matrix (you can choose N), you can also change the order with the circshift function. If you want to shift it down R rows, something like this works:
M = magic(4);
R = circshift(M, [2 0]);
to rotate ‘M’ down two rows. With colormap, it would shift the order of the colours. Another option if you want to completely invert the order is flipud.
Experiment! You can probably do what you want.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by