teaLeef
teaLeef

Reputation: 1989

Removing small values in slice

How can I delete the small values in a slice plot? In my plot, there is basically too much blue and I cannot see the red points inside.enter image description here

Or, put slightly differently:

*Is it possible delete some points in a slice plot with matlab?

slice(X,Y,Z,V,sx,sy,sz) represents the value of the volume V on the whole plans defined by sx,sy and sz. But can I choose to keep some points of these plans only?

EDIT New code:

h =slice(x,y,z,V,sx,sy,sz);
for n=1:length(h)
    set(h(n), 'alphadata',get(h(n),'cdata'), 'facealpha','flat');   
end
a = alphamap('rampup',256);
a(a<(threshold)) = 0;
a(a>(threshold)) = 0.07;
alphamap(a);

I tried with the code above. However, this is the plot I am getting: I think there is a problem with cdata (the colors) but I can't figure out what this is...

enter image description here

Upvotes: 5

Views: 1134

Answers (1)

nkjt
nkjt

Reputation: 7817

You can adjust the transparency so lower values are more transparent. First, you need the handles to your slices:

h = slice(X,Y,Z,V,sx,sy,sz);

h is not a single handle but a series of handles to the different slices. For any one handle you can change the transparency (or loop around for all n to change them all):

set(h(n),'alphadata',get(h(n),'cdata'),'facealpha','flat');

alphadata is the data for transparency - by default this is "1" (opaque), so instead for each handle you can set it to the contents of cdata. AlphaDataMapping should already be set to scaled by default - so the values in alphadata are mapped to an alphamap, just as cdata values are mapped to your colormap (more on that later).

facealpha is a setting for how the alphadata is applied to the faces of an object - needs to be changed so that the values in alphadata are actually used.

If you want to adjust how transparent values are or which are transparent, you can change the alphamap. The default map is just linear and can be seen by plot(get(gcf,'Alphamap')), where is 0 = invisible and 1 = opaque. The length of the map can vary so you have a lot of freedom in adjusting it - for example you can completely zero out the lower part if you're not interested in those values:

a = alphamap('rampup',256);
a(1:80)=0;
alphamap(a); % only changes alphamap of current figure

Read more about transparency in Matlab here.

Upvotes: 5

Related Questions