MATLAB仅打印我的图形的一部分 [英] MATLAB only prints a part of my figure
问题描述
我正在尝试在 MATLAB 中打印图形,但是它一直在搞砸,我不知道为什么.
I'm trying to print my figure in MATLAB, but it keeps screwing up and I have no idea why.
opslaan = figure(1);
plot(1:handles.aantal,handles.nauw,'-r','LineWidth',1.5);
xlabel(gca,sprintf('Framenummer (%g ms per frame)',60/handles.aantal));
ylabel(gca,'dB');
set(gca,'YGrid','on');
yAsMax = ceil( ceil(max(handles.nauw)) / 2) * 2;
axis([0 handles.aantal 0 yAsMax]);
pause(1);
print -dpng image.png
第一行只是在我的图形上绘制数据,然后标记x和y,打开网格并像我想要的那样计算y轴.这一切都很好,MATLAB在图形窗口中显示了它,就像我想要的那样.保存为.png/.jpeg/.eps时,它出错了,只打印左下角(473x355像素),其余的就消失了.
The first line is just plotting the data on my figure, then labeling x and y, turning on grid and calculating the y-axis like I want it. This all works great and MATLAB shows it like I want it in the figure window. When saving to .png / .jpeg / .eps, it goes wrong and only prints the bottom left corner (473x355 pixels), the rest just disappeared.
通过文件-> 另存为手动导出时,它可以正常工作.
When exporting manually via File -> Save As, it works correctly.
我该如何解决?
推荐答案
尝试使用以下行代替现有的打印行.
Try using the following line instead of the print line you already have.
print(opslaan,'-dpng','image.png')
print(opslaan, '-dpng', 'image.png')
另一种选择是查看imwrite
.
这篇关于MATLAB仅打印我的图形的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!