How to decide if a plot is surf or mesh based on graphics handle data?
1 次查看(过去 30 天)
显示 更早的评论
Lets say I have a 3D plot which I want to export to another format, can I in any way tell if the plot is a surface, or a mesh by analyzing the result of get(gca)/get(gcf)/get(handle)?
With
x = -3:0.1:3;
y = -3:0.1:3;
[X Y] = meshgrid(x,y);
R = sqrt(X.^2+Y.^2);
Z = R;
figure
h1 = mesh(X,Y,Z);
a1 = get(gca);
f1 = get(gcf);
J1 = get(h1);
figure
h2 = surf(X,Y,Z);
a2 = get(gca);
f2 = get(gcf);
J2 = get(h2);
the only (initial) difference I can find (unless I'm blind) is:
[J1.EdgeColor = 'flat' J2.EdgeColor = [0 0 0]]
[J1.FaceColor = [1 1 1] J2.FaceColor = 'flat']
[J1.FaceLighting = 'none' J2.FaceLighting = 'flat']
[J1.EdgeLighting = 'flat' J2.EdgeLighting = 'none']
At first I thought I could do a check
if isnumeric( faceColor ) && strcmpi( edgeColor, 'flat' )
plotType = 'mesh'
end
the EdgeColor in the example is set to black, thus being numeric, and my test is indeed wrong.
So the big question is, how can I distinguish the two without looking at the plot?
(the purpose is to export the plot to TikZ/PGF using the LaTeX package pgfplots, however, I need to find out whether to use surf or mesh).
best regards, dm
0 个评论
采纳的回答
Daniel Shub
2011-5-9
Both mesh and surf create objects of the surface class. Therefore, they have identical properties (although potentially different values). What this means is that by changing the properties you can convert the object returned by mesh into an object that is identical to the one returned by surf. The pgfplots package has different "classes" for mesh and surf (you cannot turn one into the other).
You need to go through the properties of the MATLAB object and decided, based on their values, if the object needs to be created with mesh or surf from pgfplots. I do not know pgfplots well, but I think the only time you would need to use mesh is if the MATLAB surface FaceColor property is 'None.' A FaceColor of [1, 1, 1] (i.e., white), which I think is still a surf in pgfplots.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!