필터 지우기
필터 지우기

Using colorbar with imagesc

조회 수: 2 (최근 30일)
mcl1993
mcl1993 2016년 12월 5일
댓글: Adam 2016년 12월 5일
I have imported a 500 x 500 text file and have plotted the data using imagesc. I need all the cells in the text file containing a zero to be plotted white, but colour the rest of the data ie start the colorbar from 1 and include all the data up to the maximum number, but making everything that is a zero, white.

채택된 답변

Adam
Adam 2016년 12월 5일
Do you need white to actually appear on the colourbar? Doing this can be difficult because colorbars are usually e.g. 256 or 512 values so unless you have only that many data values you will always get multiple values falling in each colour bin since the minimum you could have is a single white colour bin covering e.g. 1/256th of your data.
You can manipulate your data to make this easier, but if you don't need the white to be on the colourmap, then I would just use AlphaData to make the 0 data transparent. If you need to you could create a white patch of the size of the axes under your image, but the axes themselves are white by default so you shouldn't need to do this.
  댓글 수: 2
mcl1993
mcl1993 2016년 12월 5일
I dont need the white to be in the colorbar. If you can imagine an L shape or two rectangles, below 5 keV on each axis, this data is actually zero. The rest of the dark blue is data, but very small compared to 16,000 therefore showing up also as dark blue. I need to distinguish between data that is actually zero, and just very small compared to the maximum.
Adam
Adam 2016년 12월 5일
Then I would suggest to just create a mask for your data to use as AlphaData
e.g.
alphaMask = myData ~= 0;
set( hImage, 'AlphaData', alphaMask )

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by