Plotting a patch hides all scatter data in figure

7 次查看(过去 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])

采纳的回答

Adam Danz
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 个评论
Kevin Mohr
Kevin Mohr 2019-10-10
Thank you for your feedback. Increasing the marker size worked for me as well. Even a value as small as 1 still shows the points.
Adam Danz
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
191010 200427-Figure 1.png

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

产品


版本

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by