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.
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?
Do we have to represent the values of V on the whole plan?
Can I make "small values" transparent?
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...
Removing an Element from a Slice Items need to be removed from a slice by slicing them out. To remove an element, you must slice out the items before that element, slice out the items after that element, then append these two new slices together without the element that you wanted to remove.
To remove the first element, call remove(s, 0), to remove the second, call remove(s, 1), and so on and so forth. Hm, not really. This: s[i] = s[len(s)-1] definitely copies the last element to the element at index i . Then, return s[:len(s)-1] returns the slice without the last element.
Setting the slice to nil is the best way to clear a slice. nil slices in go are perfectly well behaved and setting the slice to nil will release the underlying memory to the garbage collector. Note that slices can easily be aliased so that two slices point to the same underlying memory.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With