Please help me with changing tick mark labels
struktura.jmeno = 'data';
struktura.data = [0.0231 0.0197 0.0260;
0.0653 0.0300 0.0330;
0.3030 0.2320 0.2700;
0.2120 0.1370 0.1650];
struktura.popis = {'Šroub','Faston','Konektor1','Konektor2'};
struktura;
bar3(struktura.data, 'grouped')
h = gca;
h.XTickLabel = struktura.popis;
And error is:
Warning: Struct field assignment overwrites a value with class "double". See MATLAB
R14SP2 Release Notes, Assigning Nonstructure Variables As Structures Displays Warning,
for details.
Thaks a lot in advance

 採用された回答

Kelly Kearney
Kelly Kearney 2014 年 11 月 4 日

1 投票

The syntax you're using there will only work in the latest release of Matlab (R2014b). In earlier versions, the graphics handle ( h) will be a double, and the warning is letting you know that you changed that double to a structure when you added a field (and doing so will not add tick labels to said axis).
To change the xticks, use
set(h, 'xticklabel', struktura.popis);

1 件のコメント

Tomas
Tomas 2014 年 11 月 4 日
編集済み: Tomas 2014 年 11 月 4 日
Thank you for your answer, but this not working :-( Warning is gone, but the labels on X axis still not be a text but numbers (1,2,3,4). Any idea?
// Ou my fault, sorry. I need ylabel. One more time sorry and thank a lot for advise.

サインインしてコメントする。

その他の回答 (1 件)

JAMEL CHAKCHAK
JAMEL CHAKCHAK 2016 年 5 月 26 日

0 投票

I have the same problem :(
x = [1 2 3 4 5];
temp_high = [37 39 46 56 67];
w1 = 0.5;
bar(x,temp_high,w1,'FaceColor',[0.2 0.2 0.5])
temp_low = [22 24 32 41 50];
w2 = .25;
hold on
bar(x,temp_low,w2,'FaceColor',[0 0.7 0.7])
hold off
grid on
ylabel('Temperature (\circF)')
legend({'Average High','Average Low'},'Location','northwest')
ax = gca;
ax.XTick = [1 2 3 4 5];
ax.XTickLdabels = {'January','Februrary','March','April','May'};
ax.XTickLdabelRotation = 45;

カテゴリ

質問済み:

2014 年 11 月 4 日

回答済み:

2016 年 5 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by