How to place figure labels
2 ビュー (過去 30 日間)
古いコメントを表示
I need to change the x-axis labels, and the following format I wrote is not working, any help!
x = [ 1.3404 1.3404 1.5011;
2.1141 2.1141 2.1591;
2.4665 2.4665 2.4935;
2.8187 2.8187 2.8591;
3.1711 3.1711 3.2464];
figure bar(x,'FaceColor','flat')
hold on
set(gca,'xticklabels')
xticklabels ({'5','5+1','5+2','5+3','5+4'})
xlabel('Number of Nodes')
ylabel('Total Power')
legend('CL1','CL2', 'CL3')
title('clusters')
hold off
3 件のコメント
dpb
2018 年 4 月 13 日
Of course it only "lasts" for one figure; the tick labels are properties of the axes and are refreshed any time a new axes is created.
You don't want to set the default labels to something for a specific figure/plot; then you've essentially broken the PLOT() command for anything else without fixing it up every time.
Instead, if you're doing this multiple times, write a script or function that you execute/call for each case and include setting the tick labels appropriately in it. You do it once in writing the function but then it's done for you automagically when you use the function/script.
In general you would not hardcode text into the function but either derive the values for the labels from the data or pass in what is appropriate for the particular case; if this is processing a bunch of data for a very specific and narrow-scope kind of analysis then it could make sense for that purpose if number and text for the labels really won't ever change.
採用された回答
Von Duesenberg
2018 年 4 月 12 日
Is this what you are trying to achieve ? :
x = [ 1.3404 1.3404 1.5011;
2.1141 2.1141 2.1591;
2.4665 2.4665 2.4935;
2.8187 2.8187 2.8591;
3.1711 3.1711 3.2464];
figure; bar(x,'FaceColor','flat')
set(gca,'xticklabels', {'5','5+1','5+2','5+3','5+4'})
xlabel('Number of Nodes')
ylabel('Total Power')
legend('CL1','CL2', 'CL3')
title('clusters')
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Axis Labels についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!