在 matlab 2014a 中使用箱线图时缺少垂直刻度
Missing vertical tick when using boxplot in matlab 2014a
我正在使用箱线图使用 matlab 2014a 绘制我的数据。我使用下面的代码绘制我的数据并旋转我的 xlabel。但是,它丢失了图中的垂直刻度。你能看到我的预期数字(右侧)并帮助我在下面的代码中添加那个勾号吗?谢谢
figure(1);
set(gcf,'color','w');
hold on;
rotation = 25;
fontSize = 12;
str={'Test 1','Test 2'};
x1 = normrnd(5,1,100,1);
x2 = normrnd(6,1,100,1);
ax1=subplot(1,2,1); boxplot([x1, x2]); title('This is result for above code','FontSize', fontSize);
% ylim([0 1]);
text_h = findobj(gca, 'Type', 'text');
for cnt = 1:length(text_h)
set(text_h(cnt), 'FontSize', fontSize,...
'Rotation', rotation, ...
'String', str{length(str)-cnt+1}, ...
'HorizontalAlignment', 'right')
end
set(ax1, 'fontsize', fontSize);
set(findobj(ax1,'Type','text'),'FontSize', fontSize);
ylabel('Temp')
boxplot
不会在 Matlab R2014a 和旧版本中自动创建 xticks(它在 R2015a 中会自动创建,并且可能也在 R2014b 中)。
您可以手动添加 xticks,如下所示:
set(ax1, 'xtick', [1 2])
我正在使用箱线图使用 matlab 2014a 绘制我的数据。我使用下面的代码绘制我的数据并旋转我的 xlabel。但是,它丢失了图中的垂直刻度。你能看到我的预期数字(右侧)并帮助我在下面的代码中添加那个勾号吗?谢谢
figure(1);
set(gcf,'color','w');
hold on;
rotation = 25;
fontSize = 12;
str={'Test 1','Test 2'};
x1 = normrnd(5,1,100,1);
x2 = normrnd(6,1,100,1);
ax1=subplot(1,2,1); boxplot([x1, x2]); title('This is result for above code','FontSize', fontSize);
% ylim([0 1]);
text_h = findobj(gca, 'Type', 'text');
for cnt = 1:length(text_h)
set(text_h(cnt), 'FontSize', fontSize,...
'Rotation', rotation, ...
'String', str{length(str)-cnt+1}, ...
'HorizontalAlignment', 'right')
end
set(ax1, 'fontsize', fontSize);
set(findobj(ax1,'Type','text'),'FontSize', fontSize);
ylabel('Temp')
boxplot
不会在 Matlab R2014a 和旧版本中自动创建 xticks(它在 R2015a 中会自动创建,并且可能也在 R2014b 中)。
您可以手动添加 xticks,如下所示:
set(ax1, 'xtick', [1 2])