mArrow3 function and text in a 3D figure
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
I'm using the mArrow3 function, but it does not work always, ussually not. The code:
hold on;
mArrow3([0 0 0],[1 0 0],'lineWidth',0.0000002,'color','red','facealpha',0.05);
mArrow3([0 0 0],[0 1 0],'lineWidth',0.0000002,'color','red','facealpha',0.05);
mArrow3([0 0 0],[0 0 1],'lineWidth',0.0000002,'color','red','facealpha',0.05);
hold off
Could you please give me any hint? It doesn't show any errors, just doesn't appear for most of the time. But on it's own it just works fine.
One more question, do you know how to put titles to X, Y and Z directions? I mean appearing it just next to the arrows.
Now about the text command. I need to put three different texts in three different places - with just text command I put everywhere the same text. Is there any similar command to the text command?
2 件のコメント
Jan
2017 年 3 月 7 日
I assume you mean https://www.mathworks.com/matlabcentral/fileexchange/25372-marrow3-m-easy-to-use-3d-arrow. Please note, that this is not obvious.
Franta Cymorek
2017 年 3 月 7 日
I have downloaded the function and it's not working properly, that's the reason I am asking here.
採用された回答
Jan
2017 年 3 月 7 日
What exactly does "most of the time" mean? Please post some code, which reproduce the problem.
The lineWidth of 0.0000002 is very small. My first idea is, that the arrow is not visible, because it is far to thin. Did you try it with something less slender?
16 件のコメント
Franta Cymorek
2017 年 3 月 7 日
編集済み: Franta Cymorek
2017 年 3 月 7 日
I would have to upload all of the codes and functions here, would take forever. I have a GUI in Matlab, I load an Excel sheet, I have 3 axes where points to be plotted in 3D are chosen with a PC mouse, then a button is pressed and the 3D curve is created. The code I have uploaded here is what is used using the mArrow3 function. Btw, I know it's not explained well, but as already written above, it would take forever upload all of the codes here. The question is meant generally.
Works only for one certain plot, not for other plots.
Jan
2017 年 3 月 7 日
I understand. I would like to help you and therefore I ask for a piece of code, which reproduces the problem. Otherwise creating an answer requires to guess, what the problem is.
You can set a breakpoint in the line, which contains the mArrow3 command and save the input values as well as the axes properties in a MAT file. This might help to reproduce the output without the need to post your complete code.
Did you try to increase the linewidth already?
Franta Cymorek
2017 年 3 月 7 日
編集済み: Franta Cymorek
2017 年 3 月 8 日
The code:
function [pointsQRS, pointsP, pointsT] = VCG (pointsQRS,pointsP,pointsT)
%pro popis principu funkce viz VCG_QRS
figure(2)
hold on
for i=2:size(pointsQRS,1)
if mod(i,2)==0
QRS=plot3(pointsQRS([i-1:i],1),pointsQRS([i-1:i],2),pointsQRS([i-1:i],3),'-k');
else
plot3(pointsQRS([i-1:i],1),pointsQRS([i-1:i],2),pointsQRS([i-1:i],3),'-g');
end
end
for i=2:size(pointsT,1)
if mod(i,2)==0
T=plot3(pointsT([i-1:i],1),pointsT([i-1:i],2),pointsT([i-1:i],3),'-b');
else
plot3(pointsT([i-1:i],1),pointsT([i-1:i],2),pointsT([i-1:i],3),'-g');
end
end
for i=2:size(pointsP,1)
if mod(i,2)==0
P=plot3(pointsP([i-1:i],1),pointsP([i-1:i],2),pointsP([i-1:i],3),'-r');
else
plot3(pointsP([i-1:i],1),pointsP([i-1:i],2),pointsP([i-1:i],3),'-g');
end
end
view(3)
grid on
hold on;
mArrow3([0 0 0],[1 0 0],'lineWidth',0.002,'color','red','facealpha',0.05);
mArrow3([0 0 0],[0 1 0],'lineWidth',0.002,'color','red','facealpha',0.05);
mArrow3([0 0 0],[0 0 1],'lineWidth',0.002,'color','red','facealpha',0.05);
hold off
Yep, I have tried it, didn't work out. What is wrong with the code? As well, do you know how to put a comment to each tip of an arrow? I have tried the text command, but didn't wokr. I mean 3 different comments.
Perhaps the ploted data have a magnitude of 1e6, such that the arrows with the length of 1 is too tiny to be seen? An opaquness or 5% is very light also. Try this:
drawnow;
xExt = abs(diff(get(gca, 'XLim')));
yExt = abs(diff(get(gca, 'YLim')));
zExt = abs(diff(get(gca, 'ZLim')));
mArrow3([0 0 0],[xExt / 10, 0, 0], 'lineWidth', 2,'color','red','facealpha', 0.5);
mArrow3([0 0 0],[0, yExt / 10, 0], 'lineWidth', 2,'color','red','facealpha',0.5);
mArrow3([0 0 0],[0, 0, zExt / 10], 'lineWidth', 2,'color','red','facealpha',0.5);
Well, something remains strange. The output is not what I expected. But at least it is visible.
Franta Cymorek
2017 年 3 月 8 日
編集済み: Franta Cymorek
2017 年 3 月 8 日
Works a lot better now, but still not perfectly.

The lines of the arrows are too much short, and, it's not atteched to the beginning. Is there a way to solve it? How can I determine attaching it to the beginning/start point of the plotted data (no matter which data are chosen)? And what is the name of function to make the lines longer where the tipes are attached?
Jan
2017 年 3 月 8 日
You can set the startpoint by defining the first input of mArrow3.
mArrow3 has many 5 star votes. But The result in your picture are looking strange. Reading the help section I see only commands for the "stemWidth" and "tipWidth".
Perhaps it is worth to try one of the many other arrows published in the FileExchange: https://www.mathworks.com/matlabcentral/fileexchange/?utf8=%E2%9C%93&term=arrow+3d
Franta Cymorek
2017 年 3 月 8 日
編集済み: Franta Cymorek
2017 年 3 月 8 日
The lenght is solved out. Could you please give me last one hint about positioning text next to the tips? I mean 3 different texts, I have tried the text command, but this is not the right one for it. For the text positioning I know it's not a part of this function.
The position of the tips are stored in the 2nd input. Therefore I assume it can be solvwed by the text() command:
text(1.1, 0, 0, 'x'); % EDITED: X,y,z instead of [X,Y,Z]
text(0, 1.1, 0, 'y');
text(0, 0, 1.1, 'z');
I've moved the string a little bit away from the tips to avoid a collision. Why do you think, that text() does not help?
Franta Cymorek
2017 年 3 月 8 日
編集済み: Franta Cymorek
2017 年 3 月 8 日
I have tried your code and didn't work out, even it deleted the xlabel, ylabel and zlabel. Looked like the second picture.
Then I have tried this code:
text([1, 0, 0],[0 0 0], 'x');
text([0, 1, 0],[0 0 0], 'y');
text([0, 0, 1],[0 0 0], 'z');
And it looked like the first picture, even the text is so small. That's is why I thnik it's not suitable for it, because it behaves weird all the time. As well the text gets overlaped.


Sorry, there was a typo in my code. You need something like:
text(1.1, 0, 0, 'x'); % Not text([1.1, 0, 0], 'x')
And of course replace the values by the positions of the tips of the arrows.
Use the 'FontSize' to adjust the size.
Franta Cymorek
2017 年 3 月 8 日
編集済み: Franta Cymorek
2017 年 3 月 8 日
In one picture it just works perfectly, no overlaping. But second picture, it ovelaps.


This is the modified code you provided and I used:
drawnow;
xExt = abs(diff(get(gca, 'XLim')));
yExt = abs(diff(get(gca, 'YLim')));
zExt = abs(diff(get(gca, 'ZLim')));
mArrow3([0 0 0],[xExt / 1, 0, 0], 'lineWidth', 2,'color','red','facealpha', 0.05);
mArrow3([0 0 0],[0, yExt / 1, 0], 'lineWidth', 2,'color','red','facealpha',0.05);
mArrow3([0 0 0],[0, 0, zExt / 1], 'lineWidth', 2,'color','red','facealpha',0.05);
text(1, 0, 0, 'Vx','FontSize',12);
text(0, 1, 0, 'Vy','FontSize',12);
text(0, 0, 1, 'Vz','FontSize',12);
I have no idea why it gets overlapped, only as you can see, it works perfectly in one case. Only different data were used. Do you have any experience with this case?
Jan
2017 年 3 月 8 日
It depends on the sizes of the axes: While one axes has sizes of the magnitude of 1000, the other is in the range of 1. If the tips of the arrows are at e.g. [xExt,0,0], the location of the text lable should be there also.
Franta Cymorek
2017 年 3 月 8 日
Exactly what I needed! Thank you!
Franta Cymorek
2017 年 3 月 8 日
編集済み: Franta Cymorek
2017 年 3 月 8 日
A question a little bit off the topic, is there a way, to change the color of an arrow and cone separately?
Jan
2017 年 3 月 9 日
I assume that this works. The code of mArrow3 does not look trivial, but with the debugger you can examine, where what is drawn.
Franta Cymorek
2017 年 3 月 9 日
Yes, this works exactly how I wished it. Is there any link describing how to change the cone color and so on?
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
