ROTATING TEXTARROW in 3D

15 ビュー (過去 30 日間)
le fou
le fou 2019 年 12 月 19 日
編集済み: le fou 2019 年 12 月 20 日
Dear All,
I am trying to find a way, to rotate the textarrow, that correspond to its data in the pie chart, what I called h2 in that code, I want to rotate the text appearing with its arrow, for example the following string : "particle1- 13%", that actually points to a specific part of the pie chart (related data), therefore when I rotate the pie chart in 3D, I want the arrow and the text to rotate in the same way, while still pointing to the same data (part of the pie chart). I tried to do something very simple, like using rotate(h2, [20 20], 360/n]); but it is not working and it generates the following error : "Error using rotate (line 33), H must contain axes children only."
thanks in advance for your help
figure1=figure('units','normalized','outerposition',[0 0 1 1]);
colormap(parula(10))
h= pie3(mat_data3(:,1), explode, repmat({''}, size(mat_data3(:,1))));
h2=annotation(figure1,'textarrow',[0.503125 0.503645833333333],...
[0.123595505617978 0.426966292134832],'String',{'particle1- 13 %'});
% Create textarrow
annotation(figure1,'textarrow',[0.3359375 0.371875],...
[0.724813727070731 0.726418863507328],'String',{'particle2- 4 %'});
% Create textarrow
annotation(figure1,'textarrow',[0.350520833333333 0.390625],...
[0.771043759243553 0.76141294062397],'String',{'particle3- 11 %'});
% Create textarrow
annotation(figure1,'textarrow',[0.372395833333333 0.409375],...
[0.802054784918726 0.773162329059978],'String',{'particle4- 1 %'});
% Create textarrow
annotation(figure1,'textarrow',[0.413541666666667 0.430208333333333],...
[0.827866640498503 0.784527956710381],'String',{'particle5- 1 %'});
% Create textarrow
annotation(figure1,'textarrow',[0.4390625 0.459375],...
[0.856986899563319 0.786516853932584],'String',{'particle6- 26 %'});
% Create textarrow
annotation(figure1,'textarrow',[0.530729166666667 0.516145833333333],...
[0.863563402889246 0.798034934497817],'String',{'particle7- 42 %'});
% Create textarrow
annotation(figure1,'textarrow',[0.561979166666667 0.540104166666667],...
[0.820960698689956 0.776200873362445],'String',{'particle8- 1 %'});
h1=title('Average Particle Occurrence', 'fontsize', 15);
n = 180;
mov(n) = getframe;
for i = 1:n
rotate(h, [20 20], 360 / n);
rotate(h1, [20 20], 360 / n);
rotate(h2, [20 20], 360 / n);
mov(i) = getframe;
end

採用された回答

le fou
le fou 2019 年 12 月 19 日
編集済み: le fou 2019 年 12 月 20 日
Hello Everyone,
I managed to find a kind of solution, so the text is rotating now, but the arrow somehow disappeared, but at least I have the rotation working, I will keep working on it, unless someone can find me a better fix,
thanks in advance
figure1=figure('units','normalized','outerposition',[0 0 1 1]);
colormap(parula(10))
h= pie3(mat_data3(:,1), explode, repmat({''}, size(mat_data3(:,1))));
h2=annotation(figure1,'textarrow',[0.503125 0.503645833333333],...
[0.123595505617978 0.426966292134832],'String',{'particle1- 13 %'});
% Find HGTransform
t = hgtransform('Parent',gca);
% Make a Transform to rotate 360 degrees on x Axis
R = makehgtform('xrotate',2*pi);
Txy = makehgtform('translate',[-1.5 1.5 0]);
% Set the Transformation Matrix
set(t,'Matrix',R*Txy);
% Set the Parent of annotation textarrow to the new Transform
set(h2,'Parent',t); % The arrows should point correctly now but it does not
% Create textarrow
h3=annotation(figure1,'textarrow',[0.3359375 0.371875],...
[0.724813727070731 0.726418863507328],'String',{'particle2- 4 %'});
% Find HGTransform
t1 = hgtransform('Parent',gca);
% Make a Transform to rotate 360 degrees on x Axis
R1 = makehgtform('xrotate',2*pi);
Txy1 = makehgtform('translate',[-1.5 -1.5 0]);
% Set the Transformation Matrix
set(t1,'Matrix',R1*Txy1);
% Set the Parent of annotation textarrow to the new Transform
set(h3,'Parent',t1); % The arrows should point correctly now
% Create textarrow
h4=annotation(figure1,'textarrow',[0.350520833333333 0.390625],...
[0.771043759243553 0.76141294062397],'String',{'particle3- 11 %'});
% Find HGTransform
t2 = hgtransform('Parent',gca);
% Make a Transform to rotate 360 degrees on x Axis
R2 = makehgtform('xrotate',2*pi);
Txy2 = makehgtform('translate',[1.5 1.5 0]);
% Set the Transformation Matrix
set(t2,'Matrix',R2*Txy2);
% Set the Parent of annotation textarrow to the new Transform
set(h4,'Parent',t2); % The arrows should point correctly now but it does not
% Create textarrow
h5=annotation(figure1,'textarrow',[0.372395833333333 0.409375],...
[0.802054784918726 0.773162329059978],'String',{'particle4- 1 %'});
% Find HGTransform
t3 = hgtransform('Parent',gca);
% Make a Transform to rotate 360 degrees on x Axis
R3 = makehgtform('xrotate',2*pi);
Txy3 = makehgtform('translate',[1.1 1.1 0]);
% Set the Transformation Matrix
set(t3,'Matrix',R3*Txy3);
% Set the Parent of annotation textarrow to the new Transform
set(h5,'Parent',t3); % The arrows should point correctly now but it does not
% Create textarrow
h6=annotation(figure1,'textarrow',[0.413541666666667 0.430208333333333],...
[0.827866640498503 0.784527956710381],'String',{'particle5- 1 %'});
% Find HGTransform
t4 = hgtransform('Parent',gca);
% Make a Transform to rotate 360 degrees on x Axis
R4 = makehgtform('xrotate',2*pi);
Txy4 = makehgtform('translate',[1.5 1 0]);
% Set the Transformation Matrix
set(t4,'Matrix',R4*Txy4);
% Set the Parent of annotation textarrow to the new Transform
set(h6,'Parent',t4); % The arrows should point correctly now but it does not
% Create textarrow
h7=annotation(figure1,'textarrow',[0.4390625 0.459375],...
[0.856986899563319 0.786516853932584],'String',{'particle6- 26 %'});
% Find HGTransform
t5 = hgtransform('Parent',gca);
% Make a Transform to rotate 360 degrees on x Axis
R5 = makehgtform('xrotate',2*pi);
Txy5 = makehgtform('translate',[1.1 1 0]);
% Set the Transformation Matrix
set(t2,'Matrix',R5*Txy5);
% Set the Parent of annotation textarrow to the new Transform
set(h7,'Parent',t5); % The arrows should point correctly now but it does not
% Create textarrow
h8=annotation(figure1,'textarrow',[0.530729166666667 0.516145833333333],...
[0.863563402889246 0.798034934497817],'String',{'particle7- 42 %'});
% Find HGTransform
t6 = hgtransform('Parent',gca);
% Make a Transform to rotate 360 degrees on x Axis
R6 = makehgtform('xrotate',2*pi);
Txy6 = makehgtform('translate',[0.8 1.1 0]);
% Set the Transformation Matrix
set(t6,'Matrix',R6*Txy6);
% Set the Parent of annotation textarrow to the new Transform
set(h8,'Parent',t6); % The arrows should point correctly now but it does not
% Create textarrow
h9=annotation(figure1,'textarrow',[0.561979166666667 0.540104166666667],...
[0.820960698689956 0.776200873362445],'String',{'particle8- 1 %'});
% Find HGTransform
t7 = hgtransform('Parent',gca);
% Make a Transform to rotate 360 degrees on x Axis
R7 = makehgtform('xrotate',2*pi);
Txy7 = makehgtform('translate',[0.7 0.7 0]);
% Set the Transformation Matrix
set(t7,'Matrix',R7*Txy7);
% Set the Parent of annotation textarrow to the new Transform
set(h9,'Parent',t7); % The arrows should point correctly now but it does not
h1=title('Average Particle Occurrence', 'fontsize', 15);
n = 180;
mov(n) = getframe;
for i = 1:n
rotate(h, [20 20], 360 / n);
rotate(h1, [20 20], 360 / n);
rotate(h2, [20 20], 360 / n);
rotate(h3, [20 20], 360 / n);
rotate(h4, [20 20], 360 / n);
rotate(h5, [20 20], 360 / n);
rotate(h6, [20 20], 360 / n);
rotate(h7, [20 20], 360 / n);
rotate(h8, [20 20], 360 / n);
rotate(h9, [20 20], 360 / n);
mov(i) = getframe;
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by