Unable to modify the X-axis and LINKAXES setting when using YYAXIS
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167995/image.jpeg)
Figure 1
To achieve this objective, the code as shown below were used to get the following graph as shown in Figure 2.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167997/image.jpeg)
Figure 2
However, there are some problem with the outputted graph as highlighted by red circle in the figure 2. The problem are
- String overlap at both left and right YY-Axis.
- The X-axis (time) of the two signal does not align perfectly.
- 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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167998/image.jpeg)
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 Kommentare
Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!