简体   繁体   中英

x axis text overlapping in matlab

My x axis text are overlapping. I am using this code--

   clear all
   A=[1 2 3 4 5 6 7]';
 b=1:length(A);
 figure(1)
 bar(A)
 title('Loss Diagram')
 xlabel('Loss factor')
 ylabel('kWh/year','fontsiz`enter code here`e',20)
 grid on

set(gca,'Xtick',b,'XtickLabel',{'Horizntl Global Irr. ' 'Effective irr. on coll. ' 'Array nominal energy ' 'PV module loss ' 'charge controller loss  ' 'Battery efficiency loss ' 'converter loss '},'fontsize',14);

![matlab image] http://filepi.com/i/HeQt8pE

You didn't ask a question, but I assume you want some way of displaying your x-axis labels without overlapping.

A solution is rotateXLabels.m , which is also build into the newest Matlab versions.

Here's an example:

A=[1 2 3 4 5 6 7]';
b=1:length(A);

figure(1)
bar(A)

title('Loss Diagram')
xlabel('Loss factor')
ylabel('kWh/year', 'FontSize', 20)
grid on

set(gca,'Xtick',b,'XtickLabel', ...
    {'Horizntl Global Irr. ', 'Effective irr. on coll. ', ...
    'Array nominal energy ' 'PV module loss ' 'charge controller loss ', ...
    'Battery efficiency loss ' 'converter loss '}, 'FontSize', 14);

rotateXLabels( gca(), 45 )

Which produces: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM