Plotting a patch hides all scatter data in figure
7 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Adam Danz
on 10 Oct 2019
Edited: Adam Danz
on 10 Oct 2019
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 Comments
Adam Danz
on 10 Oct 2019
Edited: Adam Danz
on 11 Oct 2019
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
More Answers (0)
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!