简体   繁体   中英

White lines when exporting PNG on Mac using Matlab and other programs

When I export figures in Matlab and increase resolution or magnify the image using for example export_fig test.png -m3.0 the saved image has large white lines across it.

Image without magnification:

在此输入图像描述

Image using -m3.0:

在此输入图像描述

The code used was

%% test
figure('position', [100, 100, 350, 350]);
surf(peaks(10))
colormap(jet)
caxis([-5,10])
view(0,90)
export_fig png_test.png -transparent -m3.0;
%export_fig png_test.png -transparent -m1.0; % this works, but not high
%    enough resolution

I have also had this problem with other programs on my Mac running OS X Yosemite 10.10.5, but can't seem to reproduce it at the moment.

I've tried using the reslution tag eg -r300 for export_fig, but it does the same thing.

Also I think (probably wrong) the program actually saving the image is opengl, perhaps there is a problem with this?

Any suggestions would be greatly appreciated. Thank you.

I recommend the following:

set(gcf, 'InvertHardCopy', 'off');  % keep figure from changing properties
saveas(gcf, [path,filesep,fName], 'png')

If you want to be able to do it interactively with the regular "Save figure" tool in the toolbar, use the following:

hToolbar = findall(gcf,'tag','FigureToolBar');
t = findall(hToolbar);
saveFile = findobj(t,'Tag', 'Standard.SaveFigure');
set(saveFile,'ClickedCallback',@saveFigFcn)


function saveFigFcn(~,~)
    [fName, path, filterindex] = uiputfile({'*.png'},'Save as');
    if filterindex
        set(gcf, 'InvertHardCopy', 'off');
        saveas(gcf, [path,filesep,fName], 'png')
    end
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM