MATLAB is not giving good quality eps figure, looks good in png format but looks really bad in pdf.
55 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have attached my MATLAB figure MATLAB figure (gdrive), Rendered with Painters. I normally use "saveas" function, to save figure in eps format, to be exact:
saveas(fig, 'myfigure1.eps', 'epsc');
When I use generated eps in overleaf (latex pdf) it looks very bad (seems aliased may be). See the pic below. The peculier red contours are visible. In upper blue region some weird lines like structures appears. In png it looks fine.
Actully it looks better in MATLAB figure, also looks fine in png format. See pic below. I want in eps format.
I used many functions in file exchange but couldn't find a solution. I also ovserved that if I use print command to create pdf directly, even with 6000 dpi the figure looks bad.
Can I have eps of this MATLAB figure with high quality?
0 comentarios
Respuestas (1)
chicken vector
el 14 de Jun. de 2023
Editada: chicken vector
el 14 de Jun. de 2023
The images have a better quality and more saving options (e.g. no white borders).
filepath = 'C:\Users\YourName\Desktop\filename';
export_fig(filepath,'-eps','-transparent','-r300');
14 comentarios
chicken vector
el 19 de Jun. de 2023
t's probably connected to the use of the contour function, but this is my guess.
If this is for a paper, .eps figures are in general preferable, but you can also use .pdf or high resolution .png.
Alternatively, you can convert the contour to a surface.
I don't recommend you doing this because produces a large amount of data and heavy figures which makes overleaf copilation much slower, but should work in desprate cases.
close all;
% Input:
resolutionFactor = 10;
% Load data:
fig = open('MatlabQuestion.fig');
ax = fig.Children(3);
cont = findall(ax.Children, 'Type', 'Contour');
% Re-structure:
for j = 1 : length(cont)
cont2surf(ax, cont(j), resolutionFactor);
end
% - [stacking goes here] - %
% Export figure:
export_fig('myfigureR.eps', '-eps', '-r300');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function cont2surf(ax, cont, resolutionFactor)
% Resolution:
xCurrentResolution = length(cont.XData);
yCurrentResolution = length(cont.YData);
xNewResolution = resolutionFactor * xCurrentResolution;
yNewResolution = resolutionFactor * yCurrentResolution;
% function cont2surf(ax, x, y, z)
% Increase data resolution:
xPoints = linspace(1, xCurrentResolution, xNewResolution);
yPoints = linspace(1, yCurrentResolution, yNewResolution);
xInterp = @(n) interp1(1 : xCurrentResolution, cont.XData, n);
yInterp = @(n) interp1(1 : yCurrentResolution, cont.YData, n);
[X,Y] = meshgrid(xInterp(xPoints), yInterp(yPoints));
[x,y] = meshgrid(cont.XData,cont.YData);
Z = interp2(x, y, cont.ZData, X, Y);
% Substitute contour with surface:
delete(cont);
hold on;
surf(X, Y, Z, 'Parent', ax, 'EdgeColor', 'None');
hold off;
view([0 0 1]);
ax.Children = ax.Children(circshift(1 : length(ax.Children), -1));
ax.SortMethod = 'ChildOrder';
end
Remember to change the stack order to display the graphic object as you want.
the stack is accessed through ax.Children and you can change the order as I have done in the function:
%% Example:
% Indeces for new order:
newOrder = randperm(length(ax.Children));
% Setup new order:
ax.Children = ax.Children(newOrder);
% Update stack based on Children order:
ax.SortMethod = 'ChildOrder';
Ver también
Categorías
Más información sobre Printing and Saving en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!