function beautifyBERplot() % BEAUTIFYBERPLOT Enhances a BER plot for publication-quality figures. % % This function automatically adjusts the aesthetics of an existing plot. % It sets limits based on the data already plotted and modifies the % appearance for publication-ready figures. % Set line properties for all current plot lines lines = findall(gca, 'Type', 'Line'); markers = {'o', 's', 'd', '^', 'v', '>', '<', 'p', 'h'}; % Define marker styles num_markers = length(markers); for i = 1:length(lines) lines(i).LineWidth = 1.5; % Set a thicker line width lines(i).LineStyle = '-'; % Solid lines for simplicity lines(i).Marker = markers{mod(i-1, num_markers) + 1}; % Assign markers cyclically lines(i).MarkerSize = 6; % Set marker size lines(i).MarkerFaceColor = 'auto'; % Use line color for marker face end % Change all text interpreters to LaTeX set(findall(gca, '-property', 'Interpreter'), 'Interpreter', 'latex'); % Set figure background to white set(gcf, 'Color', 'w'); % Set axis labels with LaTeX xlabel('Bit Rate in Gbps', 'Interpreter', 'latex'); ylabel('Bit Error Rate', 'Interpreter', 'latex'); % Determine x and y limits from the data in the plot x_data = []; y_data = []; for i = 1:length(lines) x_data = [x_data; lines(i).XData(:)]; %#ok % Append x data y_data = [y_data; lines(i).YData(:)]; %#ok % Append y data end x_min = min(x_data); x_max = max(x_data); y_min = 1e-4; % Ensure no negative or zero values for log scale y_max = 0.5; % Adjust axis ranges xlim([x_min, x_max]); ylim([y_min, y_max]); % Set logarithmic scale for y-axis set(gca, 'YScale', 'log'); % Customize grid and box appearance set(gca, 'Box', 'on', 'LineWidth', 1.2); % Add a thicker border grid on; grid minor; % Adjust font size and style for better readability set(gca, 'FontSize', 12, 'FontName', 'Times New Roman'); end