How can I change the LineWidth according to several conditions?

3 次查看(过去 30 天)
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 个评论
jonas
jonas 2018-4-25
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

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2018-4-25
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Identification 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by