How to rotate the symblo only in the 3D map

I want to rotate the symbol(the marker) inside the figure, how to make the marker parrallel to X-Y surface as shown in fig.2?
thanks very much in advance

 채택된 답변

Walter Roberson
Walter Roberson 2013년 2월 7일

0 개 추천

The closest MATLAB gets to this in the built-in facilities is that scatter3() creates markers as patch objects, which you could post-process to become discs.
You might be able to find something in the File Exchange; I do not recall having happened upon it, but I wasn't looking for it either.

댓글 수: 4

joe joe
joe joe 2013년 2월 7일
thanks for your quick response, Roberson! I tried as you suggested, but it seems not work for the marker rotation only. What do you mean built in facilities in scatter3. scatter3(X,Y,Z,S,C), just can change the size, color, right? do i miss something?
h = scatter3(X, Y, Z, 'filled');
ch = get(h, 'Children');
ch will now be a vector of patch() objects, each one with XData, YData, ZData containing a single coordinate of the center of the marker. The MarkerFaceColor determines whether the marker is filled or not ('none'). There is no explicit polygone stored for the marker: the only shape indicator is MarkerType. Effectively, the surface is drawn at whatever angle is appropriate, and then for each visible marker, the marker is drawn in the viewing plane, unrotated.
To change this so that you get a spacially-rotatable marker, you could go through all of those children objects and replace the XData / YData / ZData to form a disc in the appropriate plane, and probably set the MarkerType 'off' to remove the system marker.
You might want to look at the FEX contribution "plt" to see if it has something along these lines. My memory is that it has custom marker shapes, but I do not recall if the marker shapes can be 3D.
joe joe
joe joe 2013년 2월 8일
thanks roberson! I would like to try it again and let you know the results later time.
Walter Roberson
Walter Roberson 2016년 11월 18일
Note: this solution will not work from R2014b onward.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

ChristianW
ChristianW 2013년 2월 8일
편집: ChristianW 2013년 2월 8일

0 개 추천

Here is a simple basic part.
n = 100;
X = randi(n,30,1); Y = randi(n,30,1); Z = randi(n,30,1);
r = 4; % factor for radius scale
uZ = unique(Z);
cmap = jet(length(uZ));
for i = 1:length(Z)
R = r * (mean(Z)/300 + (Z(i)-min(Z))/range(Z));
[x,y] = pol2cart(0:pi/8:2*pi,R);
z = zeros(length(x));
C = cmap(uZ==Z(i),:);
patch(x+X(i),y+Y(i),z+Z(i),C,'EdgeColor','none')
end
axis tight; box on; view(23,60)
Scaling the patches for all possible inputs isnt done here. Some manual scaling can be done with r.

댓글 수: 3

True. There really isn't a lot of point in going the route of scatter3() followed by changing all the patches that scatter3() creates: might as well just do what you did here, create the patches directly.
The bit with sort() is inefficient though. You might as well use the multi-output version of unique() once before the loop.
Also, should cmap be created as length(Z) or only length() of the unique Z?
ChristianW
ChristianW 2013년 2월 8일
Both true, changed/edited the code, thanks.
joe joe
joe joe 2013년 2월 8일
편집: joe joe 2013년 2월 8일
good discussion! i learned a lot from you. thanks ,Robberson and ChristianW!

댓글을 달려면 로그인하십시오.

카테고리

질문:

2013년 2월 7일

댓글:

2016년 11월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by