如何完整显示ylabel?

问题描述 投票:0回答:1

ylabel 在图中显示了一半。 帮我解决问题,让ylabel完整显示。另外,如果 xlabel 移到 xtick 附近会更好。代码是用 Matlab 编写的。我要求在 Matlab 本身中提供一个解决方案。提前致谢。 下面是Matlab代码:

clear; 
% Change default axes fonts.
set(0,'DefaultAxesFontName', 'Times New Roman')
set(0,'DefaultAxesFontSize', 21)

% Change default text fonts.
set(0,'DefaultTextFontname', 'Times New Roman')
set(0,'DefaultTextFontSize', 21)

% Define data
x = [100, 200, 300, 400, 500];

data = [
    5.3, 7.3, 4.3, 3.3, 1.3;
    4.3, 4.3, 4.3, 5.3, 10.3;
    2.3, 7.3, 2.3, 8.3, 2.3;
    1.3, 9.3, 8.3, 7.3, 0.3;
    9.3, 2.3, 0.3, 2.3, 0.3;
    6.3, 7.3, 9.3, 6.3, 7.3;
];

datasetNames = {'A', 'B', 'C', 'D', 'E', 'F'};

% Create a 3D bar chart
figure;
bar3(data);
% Customize the axes 
set(gca, 'XTickLabel', x, 'YTickLabel', datasetNames, 'FontSize', 21); % Set x-axis labels as number of tasks

% Align labels
xlh = xlabel('Task Count', 'FontSize', 21, 'FontName', 'Times New Roman', 'FontWeight', 'normal', 'Rotation', -30);
ylh = ylabel('Method', 'FontSize', 21, 'FontName', 'Times New Roman', 'FontWeight', 'normal', 'Rotation', 37);
zlh = zlabel('Fitness', 'FontSize', 21, 'FontName', 'Times New Roman', 'FontWeight', 'normal');

% Set Z-axis limits
zlim([0.31, max(data(:))]); % Start Z-axis at 0.0018

% Set view angle for better visualization
view(45, 30);

% Adjust figure size and layout
set(gcf, 'Units', 'normalized', 'Position', [0.2, 0.2, 0.6, 0.6]);

% Adjust paper size for saving
fig = gcf;
fig.PaperUnits = 'centimeters';
fig.PaperPosition = [0 0 14.4 12.4]; 
fig.PaperSize = [13.4 11.5];  % width & height of page

% Save the figure
print('FST_D_S2.pdf','-dpdf','-r1200');

matlab
1个回答
0
投票

问题有更新。数据集名称如下:

数据集名称 = {'AAAAAA', 'BBBBBB', 'CCCCCC', 'DDDDDD', 'EEEEEE', 'FFFFFF'};

© www.soinside.com 2019 - 2024. All rights reserved.