Set new position for x label at semilogx diagram

2 次查看(过去 30 天)
  • I have a semilogx diagram and I need to change the name and the position of the x labels as shown in the two pictures attached below.My data are pairs of values. *
X_values=> Tr=[0;2;5;10;25;50;100;200;500];
Y_values1=> SSa=[0.377;0.4050;0.422;0.44;0.452;0.461;0.469;0.478];
Y_values1=> SSb=[0.378;0.421;0.451;0.488;0.514;0.539;0.562;0.59];
Y_values1=> SSc=[0.348;0.384;0.41;0.439;0.46;0.478;0.495;0.515];
  • and my code *
figure('Name','ExtremeValues','NumberTitle','off')
semilogx(Tr,SSa,'g*-')
hold all
semilogx(Tr,SSb,'b*-')
semilogx(Tr,SSc,'r*-')
set(gca,'linewidth',1.5,'fontsize',11);
xlabel('ReturnPeriod','FontSize',12,'FontWeight','bold')
ylabel('StormSurge (m)','FontSize',12,'FontWeight','bold')
set(gca,'XTickLabel',sprintf('%3.4f|',Tr))
grid on
  2 个评论
Dimitris Kokkinos
Dimitris Kokkinos 2015-1-26
I would,also, like to get grid lines only at my values position if possible!! Thanks in advance.
Dimitris Kokkinos
Dimitris Kokkinos 2015-1-26
Well I found solution to my problem.Thanks for your time. set(gca,'XTickLabel',sprintf('%3.0f|',Tr),'XTick',... [2,5,10,25,50,100,200,500],'XGrid','on','XMinorGrid','off')

请先登录,再进行评论。

回答(1 个)

Thorsten
Thorsten 2015-1-26
semilogx(Tr(2:end),SSa,'g*-')
hold on
semilogx(Tr(2:end),SSb,'b*-')
semilogx(Tr(2:end),SSc,'r*-')
set(gca, 'XTick', [2 5 10 25 50 100 200 500])
grid on
set(gca, 'XMinorTick', 'off')
set(gca, 'XMinorGrid', 'off')

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by