How do I change the x labels on a boxchart plot?
112 次查看(过去 30 天)
显示 更早的评论
I have a script for a boxchart plot, but I cannot find anywhere how to change the labels of the x axis. I want the 1, 2 and 3 replaced by
,
and
. Can anyone help me? Thanks.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/941034/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/941039/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/941044/image.png)
x=rand(3,3);
figure
hbx = boxchart(x);
xMdn = median(x);
boxw = hbx.BoxWidth;
xd = 1:numel(hbx.XData);
hold on
plot(0.5*boxw*[-1;1]+xd, [1;1]*xMdn, '-r','LineWidth',1.5)
hold off
box on
grid on
set(gca,'FontSize',14)
set(gcf, 'color', 'white')
hbx.MarkerStyle = '+';
hbx.MarkerColor = 'r';
set(gca,'Yscale','log')
0 个评论
采纳的回答
Simon Chan
2022-3-25
Try this:
x=rand(3,3);
figure
hbx = boxchart(x);
xMdn = median(x);
boxw = hbx.BoxWidth;
xd = 1:numel(hbx.XData);
hold on
plot(0.5*boxw*[-1;1]+xd, [1;1]*xMdn, '-r','LineWidth',1.5)
hold off
box on
grid on
set(gca,'FontSize',14)
set(gcf, 'color', 'white')
hbx.MarkerStyle = '+';
hbx.MarkerColor = 'r';
set(gca,'Yscale','log')
set(gca,'TickLabelInterpreter','latex');
set(gca,'XTickLabel',{'$$h^{e}_{d}$$','$$h^{c}_{d}$$','$$h^{*}_{d}$$'});
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!