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;

카테고리

도움말 센터File Exchange에서 Axis Labels에 대해 자세히 알아보기

질문:

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