Designating color to value in contourf

조회 수: 28 (최근 30일)
Jason Redding
Jason Redding 2018년 6월 15일
댓글: Jorge Pascual 2019년 12월 3일
I have a data range from 0 to ~66000 and I need to plot the color white only when z=0 in contourf. I have read through the colormap options related to contourf and none of them suit such a large data set or provide a specific enough answer. There must be an easy fix for this! Thanks in advance!
  댓글 수: 2
Walter Roberson
Walter Roberson 2018년 6월 15일
Could you confirm that white should be displayed only for z = 0 exactly , and not for z = 0.0001 or z = 1?
Are you supplying a contour level for 0 and a different contour level for the smallest non-zero value?
Jason Redding
Jason Redding 2018년 6월 15일
Yes, white should be displayed for z=0 only. My data is only counts though (all integers), so there are no decimals.
Yes, the goal is to give 0 its own contour level and then everything else (the smallest non-zero value and above) be scaled according to the data (which can change) if possible.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2018년 6월 15일
[~, hContour] = contourf(YourData, [0, other_levels_go_here]);
idx = hContour.LevelList == 0;
hContour.FacePrims(idx).ColorData = uint8([255; 255; 255; 255]);

추가 답변 (1개)

Jorge Pascual
Jorge Pascual 2019년 12월 3일
Good afternoon,
I have a picture about a foot with differents values of pressure, I would like to create a Pedobarography with this values, but as I have a 2D matrix I am having some problems. I would like to fix the maximun value in red, the lowest in blue, and then the rest of the image that isn't foot in black.
Using the answer that @Walter Roberson said I have this error " Unrecognized property 'ColorData' for class 'matlab.graphics.GraphicsPlaceholder'" or maybe I don't undertand how I have to fill the variables that he said.
Thank you in advanced.
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 12월 3일
Is idx possibly coming out empty? Is hCounter possibly coming out empty?
Jorge Pascual
Jorge Pascual 2019년 12월 3일
The matrix is about 719x272, where the values go between 0-60 and 0 is outside the foot.
So I fill de varibles in this way:
[~, hContour] = contourf(Pedobarography1, [0, 60]);
idx = hContour.LevelList == 0;
hContour.FacePrims(idx).ColorData = uint8([255; 255; 255; 255]);

댓글을 달려면 로그인하십시오.

카테고리

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

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by