Cant get plotyy to work with string x tick labels

조회 수: 1 (최근 30일)
Andrew Alkiviades
Andrew Alkiviades 2012년 9월 22일
Hi I am trying to draw a double y axis graph with string text for the x labels. I have the following code
x = 1:12;
y1 = Wind_monthly_speed;
y2 = Solar_monthly;
[AX,H1,H2] = plotyy(x,y1,x,y2);
title('Monthly Average Wind Speed and Solar Energy - Hanimaadhoo','FontSize',18)
set(get(AX(1),'Ylabel'),'String','Wind Speed (m/s)','FontSize',15)
set(get(AX(2),'Ylabel'),'String','Insolation (kWh/m2)','FontSize',15)
set(gca, 'XTick',1:12, 'XTickLabel',{'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L'})
This code gives me a graph but the numeric x tick tables seem to be getting in the way. Does anyone know how to remove them?

채택된 답변

Wayne King
Wayne King 2012년 9월 22일
편집: Wayne King 2012년 9월 22일
This has to do with how plotyy() creates two overlappying x-axes. You can work around this with the following:
[AX,H1,H2] = plotyy(x,y1,x,y2);
title('Monthly Average Wind Speed and Solar Energy - Hanimaadhoo','FontSize',18)
set(get(AX(1),'Ylabel'),'String','Wind Speed (m/s)','FontSize',15)
set(get(AX(2),'Ylabel'),'String','Insolation (kWh/m2)','FontSize',15)
set(AX,'xtick',1:12)
set(AX,'xticklabel',' ')
set(AX,'xticklabel',{'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L'});

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Two y-axis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by