Matlab: When I increase the schedule of graphs, you do not automatically update

As written above, I want to zoom in, which was created using plotyy. When I do this, it yTicksdoes not update to new visible boundaries. So this can happen if you zoom in too much so you don’t see yTicks. I found a function ActionPostCallback, but I am not working, so far so xTicksgood.

code:

figure, plotyy(1:10,1:2:20,1:10,1:0.5:5.5)

Results in:

enter image description here

+4
source share
3 answers

For some reason, plotyy defaults to setting the "Ytickmode" axes to manual.

plotyy 2 , "Ytickmode" , .

AX=plotyy(...) %this will create an axis with 2 elements one for each axis
AX(1).YTickMode='auto';
AX(2).YTickMode='auto';
+2

, YTickMode auto.

h = plotyy(1:10,1:2:20,1:10,1:0.5:5.5)
set(h, 'YTickMode','Auto')

enter image description here

:

figure

subplot(121)
h1 = plotyy(1:10,1:2:20,1:10,1:0.5:5.5)
title('Original')

subplot(122)
h2 = plotyy(1:10,1:2:20,1:10,1:0.5:5.5)
title('Zoom')
set(h2, 'YTickMode','Auto')
+4

, , 'normal' plot, plotyy. , , " " (- ). , , plotyy.

.

% Sample data
x = 1:10;
y1 = 1:2:20;
y2 = 1:0.5:5.5;

% Create axes & store handles
h.myfig = figure;
h.ax1 = axes('Parent', h.myfig, 'Box', 'off');

if ~verLessThan('MATLAB', '8.4')
    % MATLAB R2014b and newer
    h.ax2 = axes('Parent', h.myfig, 'Position', h.ax1.Position, 'Color', 'none', 'YAxisLocation', 'Right');
else
    % MATLAB 2014a and older
    ax1position = get(h.ax1, 'Position');
    h.ax2 = axes('Parent', h.myfig, 'Position', ax1position, 'Color', 'none', 'YAxisLocation', 'Right');
end

% Preserve axes formatting
hold(h.ax1, 'on');
hold(h.ax2, 'on');

% Plot data
plot(h.ax1, x, y1, 'b');
plot(h.ax2, x, y2, 'g');

linkaxes([h.ax1, h.ax2], 'x');

:

yay

Please note that I have connected only x, but you can link the axes xand ywith linkaxes.

+3
source

Source: https://habr.com/ru/post/1616373/


All Articles