Syntax for modifying 'LineWidth' in graph?

8 ビュー (過去 30 日間)
Robert
Robert 2017 年 5 月 3 日
回答済み: Matthew Eicholtz 2017 年 5 月 3 日
Hello, my apologies because I expect this is a very simple issue, but I am having difficulty modifying the 'LineWidth' attribute for a figure from the command line, my use of the 'ax.LineWidth' is obviously not correct (below).
box(1,ax.LineWidth,2)
I am using version 2017a, so I don't need to use the set/get functions, is that correct?
Thanks
  1 件のコメント
Jan
Jan 2017 年 5 月 3 日
You did not mention what you want to achieve. The figure does not have a linewidth. The shown command looks like you want to modify the width of the box around an axes? But instead of guessing what you mean, I ask you.

サインインしてコメントする。

回答 (3 件)

dpb
dpb 2017 年 5 月 3 日
Not enough context to tell for certain but looks like from variable name that ax is probably an axes handle...if so, the 'LineWidth' property is associated not with the axes but the line handle (typically returned by plot)
'box' is a property of an axes but only has values of 'off','on', though so the arguments to the function box are wrong (unless you've aliased it with something of your own definition which is strongly recommended to not do.

Robert
Robert 2017 年 5 月 3 日
I found a solution! The problem I was running into was attempting to use the syntax
box(1,ax.LineWidth,2)
which came from the help menus. However, a bit of digging led to
ax = gca; ax.LineWidth = 2;
which works. Thanks for your help!
Cheers

Matthew Eicholtz
Matthew Eicholtz 2017 年 5 月 3 日
If you have a figure,
figure;
% something plotted here...
ax = gca; %axes handle
Then to change the line width of the axes, simply use:
ax.LineWidth = 2; %or whatever number you like

カテゴリ

Help Center および File ExchangeCreating, 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