Bar figure helps with group on the x-axis

7 次查看(过去 30 天)
Hello everyone, I need help with grouping my data, where the central value on the x-axis is the corresponding number, not approximations.
x = [1.2132312 5.3413413212];
vals = [1.12234 1.34234 0.52342741238 2.4132213 3.1231232 5.123123 8.123123;5.793371156 10.506158125 1.23213 1.3123 1.5 1.5 1.5]
vals = 2×7
1.1223 1.3423 0.5234 2.4132 3.1231 5.1231 8.1231 5.7934 10.5062 1.2321 1.3123 1.5000 1.5000 1.5000
b = bar(x,vals,'grouped');
For example, the group of 7 bars that comes out below only the number 1.2132312 and for the other set the number 5.3413413212

回答(1 个)

Voss
Voss 2022-8-26
编辑:Voss 2022-8-26
Like this?
x = [1.2132312 5.3413413212];
vals = [1.12234 1.34234 0.52342741238 2.4132213 3.1231232 5.123123 8.123123;5.793371156 10.506158125 1.23213 1.3123 1.5 1.5 1.5];
b = bar(x,vals,'grouped');
set(gca(),'XTick',x)
Or this?
b = bar(x,vals,'grouped');
ax = gca();
ax.XTick = x;
ax.XAxis.TickLabelFormat = '%.10f';
Or this?
b = bar(x,vals,'grouped');
ax = gca();
ax.XTick = x;
ax.XTickLabel = {'1.2132312' '5.3413413212'};

类别

Help CenterFile Exchange 中查找有关 Bar Plots 的更多信息

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by