現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
how to know the dimension of a figure window and then draw my own according to same dimension
16 ビュー (過去 30 日間)
古いコメントを表示
If I have a figure window which is open. How can I know its dimesnion? I mean how can I know its size (length and width)? Once I know the dimesnion of the open figure window, then I want to draw my own figure window of the same dimension. How can we do that?
採用された回答
Ameer Hamza
2020 年 10 月 14 日
編集済み: Ameer Hamza
2020 年 10 月 14 日
If it is already open and you don't have its handle, then first get it
fig = gcf(); % handle of current figure;
pos = fig.Position; % contains its position and dimensions
pos is 4 element vector [x y w h]. x and y are the positions of the bottom left corner of the figure window in screen coordinates (by default in pixels). w and h are the width and height of the window (by default in pixels too). Create a new figure at the same position and with the same dimensions
fig2 = figure('Position', pos)
16 件のコメント
Sadiq Akbar
2020 年 10 月 14 日
Thank you very much Ameer Hamza for your prompt response. Yes it works. But if I have 8 figures already opened. And I have anothr 9th figure that is in current folder and is not opened.
Now if I want to make the dimesnions of the opened figures identical to the 9th figure, then how can we do that?
Ameer Hamza
2020 年 10 月 14 日
You cannot do that without opening the figure. If you already know its dimensions, then you can hard-code these values manually, but there is no automatic way without opening the .fig file
fig2 = figure('Position', [10, 10, 500, 500])
Sadiq Akbar
2020 年 10 月 14 日
Thank you very much for your 2nd prompt response. Ok I got it. If suppose I open the 9th figure also. And I find the dimension by the following command as you told me.
fig = gcf(); % handle of current figure;
pos = fig.Position; % contains its position and dimensions
Now how can I insert this dimension in those 8 figures?
Sadiq Akbar
2020 年 10 月 14 日
Thank you very much for 3rd response. No. I mean that I have opened all the 8 figures and then opened the 9th figure also. I will determine the dimension of the 9th figure according to the following command as you told me, i.e.
fig = gcf(); % handle of current figure;
pos = fig.Position; % contains its position and dimensions
Now if the 9th figure is a reference for me and I want to make the dimension of all those 8 figures (already opened) identical to the 9th figure, and I don't have their handles, then how can we do that? Say for example their names are fig1, fig2,fig3,....fig8.
Ameer Hamza
2020 年 10 月 14 日
Ok. Do something like this. Before opening the 9th figure, get the handle of the existing 8 figures
figs = findall(0, 'type', 'figure');
Then open 9th figure, get its handle and extract its position
fig = gcf(); % handle of current figure;
pos = fig.Position; % contains its position and dimensions
the run
[figs.Position] = deal(pos);
Sadiq Akbar
2020 年 10 月 14 日
Thank you very much for your 4th reponse. Indeed I am very thankful to you for your precious time that you spare for my problem.
Can we make the above a single m file.i.e. If all the 8 figures are opened by my m file.Then if I open the 9th figure also and after that I run your m file and it makes all the 8 figures dimension equal to the dimension of the 9th figure?
Ameer Hamza
2020 年 10 月 15 日
Ok. You can use the following function
function change_figures_size(fig9)
figs = findall(0, 'type', 'figure');
figs = setdiff(figs, fig9)
pos = fig9.Position;
[figs.Position] = deal(pos);
end
You can pass the handle of 9th figure to this function and it will handle the rest.
Sadiq Akbar
2020 年 10 月 15 日
Thank you very much for your 5th response. I saved your program as a function. Then all the 8 figures were opened and then I opened the 9th figure also. After that I opened your program and clicked the run button.But it gives me the following error:
>> change_figures_size
Not enough input arguments.
Error in change_figures_size (line 3)
figs = setdiff(figs, fig9)
>>
Ameer Hamza
2020 年 10 月 15 日
No, you cannot run it just like that. You need to pass the handle of 9th figure.
fig9 = openfig('9th_fig_file.fig');
change_figures_size(fig9)
Sadiq Akbar
2020 年 10 月 15 日
Indeed it worked. Thank you very much for your tireless efforts and cosistant support and help. May you live long and help others like this. Thank you once again.
Ameer Hamza
2020 年 10 月 15 日
You can post a new question and paste the link in the comment below. I will try to answer if possible.
Sadiq Akbar
2020 年 10 月 15 日
Ok thank you very much dear Ameer Hamza for your kind support and devoted help. May you live long happily.
Sadiq Akbar
2020 年 10 月 15 日
https://www.mathworks.com/matlabcentral/answers/615303-how-to-export-a-figure-into-ms-word
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)