フィルターのクリア

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