一. 全英文表示。
plot(x, y, 'b-', 'LineWidth', 2);
% 设置坐标轴刻度标签的字号
set(gca, 'FontSize', 20);
% 同时设置x轴和y轴刻度标签的字号为12 % 设置坐标轴标题和图形标题,并指定字号
xlabel('X轴', 'FontName', 'Times New Roman','FontSize', 20);
ylabel('Y轴', 'FontName', 'Times New Roman','FontSize', 20);
title('正弦函数图像', 'FontName', 'Times New Roman','FontSize', 20);
set(gcf, 'Color', 'white'); % 设置图形窗口背景为白色
set(gca, 'Color', 'white'); % 设置坐标轴区域背景为白色,如果坐标轴有网格等,可能会覆盖
二. 中英文混合表示。
此时,字体'Times New Roman'改为'NSimSun'(宋体)。
plot(x, y, 'b-', 'LineWidth', 2);
% 设置坐标轴刻度标签的字号
set(gca, 'FontSize', 20);
% 同时设置x轴和y轴刻度标签的字号为12 % 设置坐标轴标题和图形标题,并指定字号
xlabel('X轴', 'FontName', 'NSimSun','FontSize', 20);
ylabel('Y轴', 'FontName', 'NSimSun','FontSize', 20);
title('正弦函数图像', 'FontName', 'NSimSun','FontSize', 20);
set(gcf, 'Color', 'white'); % 设置图形窗口背景为白色
set(gca, 'Color', 'white'); % 设置坐标轴区域背景为白色,如果坐标轴有网格等,可能会覆盖