フィルターのクリア

Exporting/extracting field from figure property editor

5 ビュー (過去 30 日間)
Nicolas Bourbaki
Nicolas Bourbaki 2018 年 7 月 24 日
コメント済み: Nicolas Bourbaki 2018 年 7 月 25 日
The property editor for figures is very useful and I use it a lot.
Often it occurs to me that I would like to add the adjustment of a certain property right into my code, to avoid the need to redo the modification manually, once the figure gets re-generated.
Therefore, I tried to use the "File > Generate Code..." menu entry to export the code of a figure, where I put the label of the x axis lower than what is normally used.
This indeed generates the code, but I can't find the property I edited (position of x axis label) nowhere in the generated code.

回答 (1 件)

James Clinton
James Clinton 2018 年 7 月 24 日
編集済み: James Clinton 2018 年 7 月 24 日
You can get the Position of the xlabel by using the get function on the figure handle and its properties, as in the following:
h = gcf; % get current figure handle
axObjs = get(h, 'Children'); % gets axes properties
label = get(axObjs, 'Xlabel'); % gets xlabel properties
pos = get(label, 'Position'); % returns the location of the x axis label
Additionally, you can set the property via the following:
h.Children.XLabel.Position = [x y z];
  1 件のコメント
Nicolas Bourbaki
Nicolas Bourbaki 2018 年 7 月 25 日
Thanks a lot for your quick answer. It helps me a lot, because it shows the underlying system, which can be used to edit also other properties of other objects.

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

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by