
Plotting a patch hides all scatter data in figure
조회 수: 1 (최근 30일)
이전 댓글 표시
I am trying to plot cubes (really just groups of patches using the function found here: https://www.mathworks.com/matlabcentral/fileexchange/15161-plotcube ) as well as 3D scatter data on the same plot. However, every time a patch is rendered on the figure, it hides all scatter data. I have tried reordering the creation of the objects in order to have the scatter data be shown, forcing the scatter data to the top using uistack(scatterObj,'top'), and messing with the rendering options to no avail.
The following code is a simplified version of what I am trying to do in the end, but it demonstrates the issue. My questions are:
Is there some property of patches that I have not yet found that causes this behavior?
Is there a better way of rendering these rectangles?
Is there some inherent issue with the way that I am trying to acheive this functionality?
% scatterData =
%
% X: [1x4096 double]
% Y: [1x4096 double]
% Z: [1x4096 double]
% C: [1x4096 double]
%
% cubeData =
%
% Edges: [8.6500 1.5900 2.3200]
% Origin: [4.7000 -18.7500 0]
% Alpha: 0.1000
% Colors: [0.0596 0.6596 0.1734]
close all
figure()
scatterObj = scatter3(scatterData.X,scatterData.Y,scatterData.Z,0.5,scatterData.C)
hold on
plotcube(cubeData.Edges,cubeData.Origin,cubeData.Alpha,cubeData.Colors)
xlim([-50 50])
ylim([-50 50])
zlim([-10 10])
댓글 수: 0
채택된 답변
Adam Danz
2019년 10월 10일
편집: Adam Danz
2019년 10월 10일
Works for me (see below). The marker size in your question is quite small (0.5) but with 4096 points, you should see something. The markesize below is 30, for comparison. Unlike other markers, scatter dot size units are points-squared. The size property is an area of points.
Have you tried restarting matlab? Have you tried setting the alpha value in plotcube() to 1.0 so that there is no transparency? If the probelm persist, what is the value of info = rendererinfo(gca) where gca is the handle to your axes?
figure()
scatterObj = scatter3(rand(1,30),rand(1,30),rand(1,30),50,rand(30,3),'MarkerFaceColor', 'flat')
hold on
plotcube([.5 .5 .5],[.2 .2 .2],0.1,[0 0 1])

댓글 수: 3
Adam Danz
2019년 10월 10일
편집: Adam Danz
2019년 10월 11일
Good!
The lesson is that scatter uses different units than the other plotting markersize properties.
Scatter units are an area in points squared.
Plot units are linear in points (not squared) where 1 point is 1/72 of an inch.
So, to equate the plot markersize with scatter markersize,
sqrt(plotMarkerSize) = scatterMarkerSize
plotMarkerSize = scatterMarkerSize^2

추가 답변 (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!

