In Scatter plot, make the largest data on the top
4 次查看(过去 30 天)
显示 更早的评论
Dear Mathwork
I am using "scatter3" to obtain the 4D image with colorbar.
However, only very few data shows in the upper limit region and it will be covered by the other dots( red arrow)
Is there anyway to make sure these "larger" one alway on the top of the figure?
I try to manipulate the sequence of the raw data (matrix) but it did not work.
( The scale of the xlim, ylim or caxis need to be fix like this)
1 个评论
DGM
2022-1-15
If you're using scatter3() but you're only using view(2), can't you use the cdata vector to order the points on the depth axis of the plot?
Something like this
N = 1000;
x = rand(N,1);
y = randn(N,1);
c = rand(N,1);
h = scatter3(x,y,c,30,c);
h.MarkerFaceColor = 'flat';
colorbar
view(2)
Markers with higher values on the color scale are closer to the camera.
But if you're using scatter3() for something else, idk what that'd be. I don't know how your data is arranged.
回答(2 个)
Star Strider
2022-1-15
Since the data are being plotted with scatter3, experiment with the view function to rotate the 3D figure to display it as desired, since rotating the axes could do that.
0 个评论
Image Analyst
2022-1-15
Maybe try sorting so that the higher value points are plotted last. Possibly (untested)
% Sort Z so that bigger values are at the bottom.
[zSorted, sortOrder] = sort(z, 'ascend');
% Sort x and y the same way so as to keep rows together.
xSorted = x(sortOrder);
ySorted = y(sortOrder);
cMap = turbo(length(x)); % Make colormap.
scatter3(xSorted, ySorted, zSorted, 30, cMap, 'filled')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!