フィルターのクリア

Plot axis limits different between figure and print

4 ビュー (過去 30 日間)
AR
AR 2022 年 8 月 24 日
コメント済み: AR 2022 年 8 月 25 日
I'm really not sure how to phrase this question to be clear, and am surprise that I never noticed this before. Perhaps because I rarely print figures.
I create a plot using the plot command. Something like this:
h = figure;
plot(x, y);
h.Position = [100 100 800 480];
set(h, 'PaperPositionMode', 'auto');
grid on; hold off; ax1 = gca;
I draw rectangles and create text boxes, based on XTick and YTick values. I also make use of xlim & ylim values to set positions of other text boxes. But nowhere am I setting xlim or ylim manually. Finally, I print the plot figure using print, as follows:
print(gcf, ['somefilename' '.png'], '-dpng');
The figure window created above matches the printed png file. However, both these seem to set the ylim scale poorly. When I grab the figure window and resize it (make larger), the ylim scale changes and seems to get set well. I don't know why this is. It's problematic because this setting doesn't get into the png file. How do I fix this, so that the printed png file has the better y-axis scale set?

採用された回答

Voss
Voss 2022 年 8 月 25 日
What happens if you resize the figure before calling print()?
  1 件のコメント
AR
AR 2022 年 8 月 25 日
Thanks - given how it works, this makes sense. I tried it using the position property to reset figure size larger, and now it seems to print with the correct axis scales. I may have a follow-on question later, but I think I should be able to work it out with this.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by