How I can change the arrow head and style in a compass plot?
21 views (last 30 days)
Show older comments
I have a compass plot with about 60 arrows of different angles and lengths. Now, I would like to change the arrows to just straight lines without arrow heads in a compass plot. How can I do that?
thank you for any help!
0 Comments
Accepted Answer
dpb
on 15 Jul 2021
Edited: dpb
on 16 Jul 2021
That's not easy -- the arrowheads are part of the lines so they're not separate objects that can be changed independently of the line.
But, it's not hard to draw using polar -- using the example data from the doc for compass
% sample data
u = [5 3 -4 -3 5];
v = [1 5 3 -2 -6];
% the engine
[th,r]=cart2pol(u,v); % convert to polar coordinates
th=[zeros(size(th));th]; % augment with origin points
r=[zeros(size(r));r];
hP=polar(th,r); % plot on polar axis
produces
ADDENDUM
Actually, on reflection, it's not so hard after all -- the arrow line data points are the last three of each set for each line so
hC=compass(u,v); % return line handles
for i=1:numel(hC)
hC(i).XData(end-2:end)=nan; % HG won't display NaN points (arrows)
end
Trick is to let the builtin feature of handle graphics to not display points if are ~finite() instead of thinking of trying to change a property of the line--change the data instead.
More Answers (0)
See Also
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!