Clear Filters
Clear Filters

arrow on vertical line doesn't look vertical

6 views (last 30 days)
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):
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 Comments
Steven Lord
Steven Lord on 18 Mar 2024
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?
NaviD
NaviD on 18 Mar 2024
here is hc:
hc=annotation('doublearrow','color',C{ii});
and the variables are attached.
Thanks
Navid

Sign in to comment.

Accepted Answer

Voss
Voss on 18 Mar 2024
Edited: Voss on 18 Mar 2024
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='--';

More Answers (0)

Community Treasure Hunt

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

Start Hunting!