Clear Filters
Clear Filters

How can I change the LineWidth according to several conditions?

3 views (last 30 days)
I am applying a compass plot and I would like the line's width changes according to certain conditions depending on one variable numress. I would like that if 0<numress<10 the LineWidth in plot plot is 0.5, if 10<numress<50 the LineWidth is 2. And so on
I tried this but does not work:
h=compass(u,v,'r')
if (0<=numress) & (numress<=10)
h.LineWidth=0.5
end
if (10<numress) & (numress<=50)
h.LineWidth=2
end
if (50<numress) & (numress<=100)
h.LineWidth=4
end
.
.
.
if (500<numress) & (numress<=550)
h.LineWidth=22
end
get(h,'LineWidth')
I tried with: get, set but the lines width do not change in my compass plotting. Can you please help me with this problem? Thank you
  1 Comment
jonas
jonas on 25 Apr 2018
set(h,'linewidth',10)
should change all the lines stored in the handle 'h'. If you want to change specific lines then you must specify those lines as h(1), h(2)... etc

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 25 Apr 2018
Often you pass in the line width. So compute it in advance, then pass it in when you call compass():
h=compass(u, v, 'r', 'LineWidth', lineWidth); % lineWidth value computed in advance.

More Answers (0)

Categories

Find more on Graphics Object Identification in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!