Setting LineWith property for all lines by point-notation

조회 수: 4 (최근 30일)
Udo Kessler
Udo Kessler 2016년 11월 19일
댓글: Walter Roberson 2016년 11월 20일
Hi,
Why can't the LineWidth property be set by point notation (for all Children of an axes object at once)? As far as i know, this worked in some earlier version - but i'm not sure about this. I'm using Matlab R2016b.
Example:
y = rand(10, 3);
x = 1:10;
hAx = axes();
plot(hAx, x, y);
%hAx.Children.LineWidth = 5; % <-- this won't work
set(hAx.Children, 'LineWidth', 5) % ..but this
Then again, this will work (for line 1):
hAx.Children(1).LineWidth = 3;
Children is a array (of lines), so setting all its values by a scalar should be possible(?)
The errormessage is: Expected one output from a curly brace or dot indexing expression, but there were 3 results.
Greetings and thanks in advance!

채택된 답변

Udo Kessler
Udo Kessler 2016년 11월 19일
편집: Udo Kessler 2016년 11월 19일
Thank you, yes, your code works. My understanding in Matlab types, fields, cells ..and so on (and how to operate with them) is too small, i think - i hope my english is a litte better :) I have to learn more about all those things before going on.
Calling the LineWidth field brings 3 single answers, instead of an array (what i thought).
hAx.Children.LineWidth
ans =
0.5000
ans =
0.5000
ans =
0.5000
Edit: hAx.Children is a array of handles to graphic objects (Lines). Those Line-Objects each have a field LineWidth - and those are returned singly when using hAx.Children.LineWidth. Therefore i get 3 answers. Is that correct? And also therefore i cannot simple set them all at once by assigning a value to that structure field ..LineWidth ?

추가 답변 (1개)

Walter Roberson
Walter Roberson 2016년 11월 19일
When you use dot notation you are pretty much using structure semantics so haX.Children.LineWidth is pretty much structure expansion
[haX.Children.LineWidth] = deal(5)
Might possibly work, perhaps

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by