Set axes properties in a loop
8 ビュー (過去 30 日間)
古いコメントを表示
Many times I want to set the axes properties with a loop. Here is an example of how I am currently doing it:
ax = gca;
axs = 'XYZ';
for k = 1:3
ax.([axs(k) 'Label']).String = sprintf('A_%d (g/cm^2)',k); % label axis units
end
Is there a better way to do this?
0 件のコメント
回答 (1 件)
Thorsten
2016 年 8 月 16 日
編集済み: Thorsten
2016 年 8 月 17 日
In this case I think that the for loop is kind of overkill. Without a loop, it is much easier to understand what's going on:
ax.XLabel.String = 'A_1 (g/cm^2)';
ax.YLabel.String = 'A_2 (g/cm^2)';
ax.ZLabel.String = 'A_3 (g/cm^2)';
3 件のコメント
Thorsten
2016 年 8 月 17 日
I see. Please post the complete example such that we can run the code. For example, nodelist is missing, and a command like plot or surf to show the data.
参考
カテゴリ
Help Center および File Exchange で Axis Labels についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!