arrow on vertical line doesn't look vertical
조회 수: 6 (최근 30일)
이전 댓글 표시
Hi
I am plotting vertical lines with double arrow using this code (which is part of another code):
hc.Parent = hf.CurrentAxes;
hc.X = [1000*mm(row(ii)) 1000*case_res_straight_hyp(closestIndex_f_peak,3)];
hc.Y = [ffr_total_interp(row(ii),ii) case_res_straight_hyp(closestIndex_f_peak,4)];
diff_c(ii)=-ffr_total_interp(row(ii),ii)+case_res_straight_hyp(closestIndex_f_peak,4);
hc.Head1Style='plain';
hc.Head2Style='plain';
hc.Head1Length=10;
hc.Head2Length=10;
hc.Head1Width=10;
hc.Head2Width=10;
hc.LineWidth=1;
hc.LineStyle='--';
However, the arrows do not look vertical and inline, as (dashed vertical lines):
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1644621/image.png)
Can you please advise how to solve this issue? also I need the vertical lines (both solid lines and dashed line) to attach to arrows. I appreacite it if you could comment on this issue as well.
Thanks
Navid
댓글 수: 2
Steven Lord
2024년 3월 18일
What is hc and how did you create it?
What are the contents of the variables you've used but not defined in your code?
채택된 답변
Voss
2024년 3월 18일
편집: Voss
2024년 3월 18일
You can get problems like those when the annotation is in an axes, which doesn't appear to be officially supported. Note that only figures, uipanels, and uitabs are listed as valid containers for an annotation:
You might have better luck using a function that is intended for making annotations in an axes, for instance this one from the File Exchange:
An example usage follows.
X = [86 85];
Y = [0.85 0.96];
First, reproducing the problem, using the built-in annotation function in an unsupported manner:
hf = figure();
axes(hf,'XLim',[0 150],'YLim',[0.7 1]);
hc = annotation('doublearrow','color',[1 0 0]);
hc.Parent = hf.CurrentAxes;
hc.X = X;
hc.Y = Y;
hc.Head1Style='plain';
hc.Head2Style='plain';
hc.Head1Length=10;
hc.Head2Length=10;
hc.Head1Width=10;
hc.Head2Width=10;
hc.LineWidth=1;
hc.LineStyle='--';
Now, doing the same thing using the FEX submission Annotate:
hf = figure();
axes(hf,'XLim',[0 150],'YLim',[0.7 1]);
hc_obj = Annotate(hf.CurrentAxes,'doublearrow',X,Y,'Color',[1 0 0]);
hc = hc_obj.Primitive;
hc.Head1Style='plain';
hc.Head2Style='plain';
hc.Head1Length=10;
hc.Head2Length=10;
hc.Head1Width=10;
hc.Head2Width=10;
hc.LineWidth=1;
hc.LineStyle='--';
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!