Filter löschen
Filter löschen

Using colorbar with imagesc

2 Ansichten (letzte 30 Tage)
mcl1993
mcl1993 am 5 Dez. 2016
Kommentiert: Adam am 5 Dez. 2016
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.

Akzeptierte Antwort

Adam
Adam am 5 Dez. 2016
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 Kommentare
mcl1993
mcl1993 am 5 Dez. 2016
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 am 5 Dez. 2016
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 )

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by