Saving a figure with multiple graphs
조회 수: 19 (최근 30일)
이전 댓글 표시
Hi all, Assume that I have the following plot: fig = plot(t,xt, t, yt);
Now, if i want to save such a plot using saveas(fig,'ddddd.jpg'), I get into trouble. It seems to be because fig is now a 2x1 handle which probably saveas is not supporting ( I am not sure though). I have tried hgsave. But, the jpg file was not opening. Any comments?
댓글 수: 0
답변 (1개)
Matt Kindig
2013년 4월 17일
saveas() takes a figure handle. The output of a plot() command is a line handle (or a 2x1 vector of line handles, as you have it). Instead, do this:
plot(t,xt, t, yt);
fig = gcf;
saveas(fig, 'dddddd.jpg');
This should work.
댓글 수: 2
Matt Kindig
2013년 4월 18일
편집: Matt Kindig
2013년 4월 18일
Payam, I think you are confused as to what 'fig' is. The handle 'fig' (which I have get set to the output of the gcf() function), is a handle to a figure, which doesn't have those properties at all.
Rather, you need to set the output of the plot() command (which outputs a line handle with properties such as 'lineWidth', 'MarkerSize', etc.) to a variable. Such as:
h = plot(t, xt, t, yt);
% h will be a 2x1 vector of LINE (not figure) handles
set(h(1), 'lineWidth', 2, 'MarkerSize, 5, ...); %set first line properties
set(h(2), 'lineWidth', 5, 'MarkerSize', 10, ...); %set second line properties
%you can also set a bunch of line handles to the same properties, using:
set(h,'lineWidth', 3, 'MarkerSize', 8, ....);
참고 항목
카테고리
Help Center 및 File Exchange에서 Printing and Saving에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!