Why do certain line markers show up faded when saving high resolution images using print?

I am saving MATLAB figures as high resolution .png files to use in a paper. Version is R2016a. The markers for triangles, squares, diamonds, and others show up fine in the MATLAB figure, but are faded when I open the .png file. Circle markers and lines are unaffected. Changing the lineWidth makes then too dark when >1, and does not have an efffect <=1. Chaning to a .tif or.jpeg did not help. I attached the saved picture and a picture I saved manually using the menu in the figure. Here is the original reference: https://dgleich.github.io/hq-matlab-figs/ Here is the code along with some random data. Any help would be appreciated as I could not find anything online. Thank you.
clear
close all
clc
x=linspace(1,10);
y1=linspace(7,7);
y2=linspace(5,5);
y3=linspace(3,3);
y4=linspace(1,1);
hold all
plot(x,y1,'k')
plot(x,y2,'ok','MarkerSize',7)
plot(x,y3,'^k','MarkerSize',7,'LineWidth',0.9)
plot(x,y4,'^k','MarkerSize',7,'LineWidth',1.1)
axis([1, 10, 0, 10]);
width = 6.5; % Width in inches
height = 3.55; % Height in inches
alw = 0.75; % AxesLineWidth
fsz = 11; % Fontsize
lw = 1.5; % LineWidth
msz = 8; % MarkerSize
% Here we preserve the size of the image when we save it.
set(gcf,'InvertHardcopy','on');
set(gcf,'PaperUnits', 'inches');
papersize = get(gcf, 'PaperSize');
left = (papersize(1)- width)/2;
bottom = (papersize(2)- height)/2;
myfiguresize = [left, bottom, width, height];
set(gcf,'PaperPosition', myfiguresize);
pos = get(gcf, 'Position');
set(gcf, 'Position', [pos(1) pos(2) width*100, height*100]); %<- Set size
set(gca, 'FontSize', fsz, 'LineWidth', alw); %<- Set properties
% Save the file as PNG
print('saved_file','-dpng','-r600');

Answers (1)

Export it as eps:
print(gcf, 'test.ps', '-deps2')
Including this in Word works perfectly - only the preview on the screen looks coarse, but the output to paper or a PDF is nice.
I use GhostScript to convert the EPS to other formats on demand.
For output problems it is worth to give this a trial: https://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig

4 Comments

print(gcf, 'test.eps', '-deps2')
Actually did not work for some reason. Looked coarse in Word and in the pdf I made from that. Did not try printing it. Downloading GhostScript and implementing it through eps2xxx did the trick though:
print(fileoutname,'-depsc2','-r600');
[result,msg] = eps2xxx([fileoutname,'.eps'],{'png'},'C:\Program Files\gs\gs9.21\bin\gswin64c.exe');
Here are the links:
https://www.mathworks.com/matlabcentral/fileexchange/6858-eps2xxx
https://www.ghostscript.com/download/
Thanks!
On closer examination, even GhostScript did not work. It makes all the markers too dark, but at least they are the same width. Even export-fig isn't working.
I narrowed the problem down to the resolution. Using the default resolution prints the markers fine, but the image looks lousy.
export_fig test -png
As I raise the resolution the markers that are not circles progressively get lighter.
export_fig test -png -r600
Same behavior for the basic print function. Any solution ideas would be appreciated.
I do not observe the problem using 2016b.
It is surprising that the output in Word looks ugly. This is expected only, when the figure renderer is OpenGL. Is this the case for you?
I do not see any evidence of OpenGL, but it is a university computer so I am not positive. The pdf does look better than when it is sitting in Word, but everything still looks way to dark like it is bolded. I am using 2016a.
I think I have managed to work around it enough though. Thank you for your help.

Sign in to comment.

Asked:

on 29 Jun 2017

Commented:

on 29 Jun 2017

Community Treasure Hunt

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

Start Hunting!