Unable to modify the X-axis and LINKAXES setting when using YYAXIS

1 次查看(过去 30 天)
Dear all, the objective was to plot a double YYaxis for a two different signal. In addition, the X-axis will have two different Xlabel at the bottom and top as shown in Figure 1
Figure 1
To achieve this objective, the code as shown below were used to get the following graph as shown in Figure 2.
Figure 2
However, there are some problem with the outputted graph as highlighted by red circle in the figure 2. The problem are
  1. String overlap at both left and right YY-Axis.
  2. The X-axis (time) of the two signal does not align perfectly.
  3. The tick at top-X_axis (for the string X-axis label) mirrored onto bottom-X_Axis and vice versa for the tick at the bottom (numeric label @ time in hour) reflected at the top X-axis.
In addition, whenever the LINKAXES was enable,the amplitude scaling between the two signal was distorted a shown in the Figure 3.
Figure 3
I really appreciate if someone can point what I have been overlooked. To help the discussion, I attached together the mentioned code and mat file together with this thread.
Thanks in advance!
load('st_data.mat');
yyaxis right
errorbar(st_X_hour, st_Vec_Y1_mean, st_Vec_Y1_Sd, '--x','MarkerSize',15)
ax1=gca;
set(ax1, 'Xtick', st_Xaxis_intrmit, 'XTickLabel',st_XLabel,'XAxisLocation','top'); xtickangle(90)
hold on
ax1_pos = ax1.Position; ax2=axes('Position', ax1_pos,'XAxisLocation','bottom','Color','none');
yyaxis left;
plot(st_X_hour,st_Y2,'Parent',ax2)
hold on
scatter(st_Xaxis_intrmit,st_Vec_Y2)
%%Please enable this to get the problem as in Figure 3
% linkaxes([ax1 ax2], 'xy')

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Grid Lines, Tick Values, and Labels 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by