我试过这段代码:
boxplot(randn(10,98)','notch','on')
set(0,'DefaultAxesFontName', 'Cambria Math')
ylabel('Normalized Parameter');
set(gca,'FontSize',14,'fontWeight','bold');
set(gca,'TickLabelInterpreter','tex');
set(gca,'XTickLabel',{'a_{0}','a_{1}','a_{2}','a_{3}','a_{4}','b_{1}','b_{2}','b_{3}','b_{4}','w'})
color = 'b';
h = findobj(gca,'Tag','Box');
for j=1:length(h)
patch(get(h(j),'XData'),get(h(j),'YData'),color,'FaceAlpha',1);
end
lines = findobj(gcf, 'type', 'line', 'Tag', 'Median');
set(lines,'linewidth',1, 'Color', 'r');
如何更改边缘和中线颜色?
答案 0 :(得分:1)
以下是一个固定代码:
g = {'a_{0}','a_{1}','a_{2}','a_{3}','a_{4}','b_{1}','b_{2}','b_{3}','b_{4}','w'};
bx = boxplot(randn(10,98).',g,'notch','on')
ax = gca;
set(0,'DefaultAxesFontName', 'Cambria Math')
ylabel('Normalized Parameter');
set(ax,{'FontSize','FontWeight','TickLabelInterpreter'},{14,'bold','tex'});
h = get(bx(5,:),{'XData','YData'});
for k=1:size(h,1)
patch(h{k,1},h{k,2},[0.4 0.8 0.85]);
end
ax.Children = ax.Children([end 1:end-1]);
主要的错误是你把补丁放在方框的上方,所以最后一行是固定它。