Diferent exporting outputs from figure to png fila in versionn2025. It worked fine in2024 version. Any changes we should know?

10 views (last 30 days)
I create one figure with exactly the same code, but if running in matlab 2024 it work fine and th e export output is the same to figure on screen. But if I do the same with the same program opening it in matlab 2025 the formatiing became practically uncontrollable and the expor image is ugly and too different what <i'm seeing on screen.I wil include 4 images created with the same code, but one in matlab 2024 and the other one in 2025 version, and its respectives exportated png files.You willse the difference,
If someone coul explain how to fix this bugnin 2025 version instead of keep working in 2024 v.?Version 2024b
Version 2025b
The code used (thw whole program) was the same
%======================= GRAFICO ====================%
% Adaptación exacta a tu fragmento + 2 curvas (ajuste y Padé).
fig1 = figure('Position', [200, 200, 1100, 700]);
% Polinomio -> aquí usamos la curva de AJUSTE como 'principal' (azul)
x_grafica = tt;
y_grafica = curva_ajuste;
plot(x_grafica, y_grafica, '-', 'LineWidth', 2, 'Color', "#2173FF", ...
'DisplayName', 'Ajuste mínimos cuadrados');
hold on;
% Añadimos la curva de Padé (naranja punteada)
plot(tt, curva_pade, '--', 'LineWidth', 2, 'Color', "#FF6B00", ...
'DisplayName', 'Padé [2/1], t_0=1.5');
% Puntos experimentales (negro relleno)
vector_x = t; vector_y = d;
plot(vector_x, vector_y, 'o', 'MarkerSize', 5, 'MarkerFaceColor', 'k', ...
'LineWidth', 2, 'DisplayName', 'Datos');
% Configurar la gráfica
grid on;
xlabel('t', 'FontSize', 14, 'FontWeight', 'bold');
ylabel('d(t)', 'FontSize', 14, 'FontWeight', 'bold');
% Título en dos líneas
titulo_1 = 'Ajuste no lineal (Gauss-Newton) y aproximante de Padé [2/1]';
titulo_2 = sprintf('\\alpha = %.6g, \\beta = %.6g, t_0 = 1.5', alfa, beta);
title({titulo_1, titulo_2}, 'FontSize', 12, 'FontWeight', 'bold');
legend('Location', 'best', 'FontSize', 10);
% Cuadro de texto con información
dim = [0.15 0.72 0.25 0.15];
str = {sprintf('N puntos: %d', length(vector_x)), ...
sprintf('SSE ajuste vs datos: %.6g', SSE_ajuste_vs_datos), ...
sprintf('SSE Padé vs datos: %.6g', SSE_pade_vs_datos), ...
sprintf('SSE Padé vs ajuste: %.6g', SSE_pade_vs_modelo)};
annotation('textbox', dim, 'String', str, 'FitBoxToText', 'on', ...
'BackgroundColor', 'white', 'EdgeColor', 'black', ...
'LineWidth', 1.5, 'FontSize', 9);
% Tamaño físico del gráfico (en cm) y márgenes blancos
set(fig1, 'PaperUnits', 'centimeters');
set(fig1, 'PaperPosition', [0 0 18 12]); % ancho x alto en cm
set(fig1, 'PaperSize', [18 12]); % igual que PaperPosition
hold off;
% EXPORTAR GRÁFICO (PNG, 300 ppp)
nombre_png = sprintf('ajuste_pade_%s.png', stamp);
fprintf('Exportando gráfico como: %s\n', nombre_png);
print(fig1, nombre_png, '-dpng', '-r300');
fprintf('Gráfico exportado exitosamente con resolución de 300 ppp.\n\n')

Answers (1)

Leepakshi
Leepakshi on 21 Nov 2025 at 8:36
Hey Sergio,
Reducing the font size might make the images look similar.
% Per Plot:
set(gca,'FontSize',10); % axes
tickstitle('Title','FontSize',12);
xlabel('X','FontSize',12);
ylabel('Y','FontSize',12);
% Global Default:
set(groot,'DefaultAxesFontSize',10);
set(groot,'DefaultTextFontSize',10);
Add this to startup.m for persistence.
This sets the default font size for axes and text globally for your MATLAB session.
Alternatively, You can try changing preferences:
Go to Home > Preferences > MATLAB > Fonts to adjust UI and axes label fonts.
Refer to below documentation for fontsize:
Hope it helps!

Categories

Find more on Line Plots in Help Center and File Exchange

Products


Release

R2025b

Community Treasure Hunt

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

Start Hunting!