# Breaking the axis of plots

3 visualizaciones (últimos 30 días)
HC98 el 23 de Jun. de 2023
Respondida: Star Strider el 24 de Jun. de 2023
How can I do something like this in MATLAB without using any external pagkages or functions? Thanks
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Angelo Yeo el 23 de Jun. de 2023
Why don't you take a look at the post below and see one of answers?

Iniciar sesión para comentar.

### Respuestas (2)

Star Strider el 24 de Jun. de 2023
Perhaps this —
x = [linspace(0, 10, 21); linspace(40, 42.5, 21)]; % Create Data
y = [sin(x(1,:)*2*pi*0.11); sin(x(2,:)*2*pi*0.15+2.6)]; % Create Data
figure
subplot(1,2,1)
plot(x(1,:), y(1,:)) % Plot First Group
Ax1 = gca;
yt = Ax1.YTick; % Get Y-Tick Values
tl = Ax1.TickLength(1)*20;
yl1 = ylim;
hold on
plot(([0;tl]*ones(size(yt))), [1;1]*yt, '-k') % Create New Y-Yicks
hold off
% grid
Ax1.YAxis.Visible = 0; % Turn Off Y-Axis
xline(0)
text(zeros(size(yt))-0.05*diff(xlim), yt, compose('%.1f',yt), 'Vert','middle', 'Horiz','right') % Label New Ticks
text(max(xlim)*[1 1]-0.04, [min(ylim) max(ylim)], '/')
subplot(1,2,2)
plot(x(2,:), y(2,:)) % Plot Second Group
% grid
ylim(yl1)
Ax2 = gca;
Ax2.YAxis.Visible = 'off'; % Turn Off Y-Axis
xline(max(xlim), '-k')
hold on
plot((max(xlim)-[0;tl*0.25]*ones(size(yt))), [1;1]*yt, '-k') % Create New Y-Yicks
hold off
text(max(xlim)+zeros(size(yt))+0.15*diff(xlim), yt, compose('%.1f',yt), 'Vert','middle', 'Horiz','right') % Label New Ticks
text(min(xlim)*[1 1]-0.05, [min(ylim) max(ylim)], '/')
This is not at all robust and will likely require tweaking with different data. The File Exchange functions are likely better, since I would assume that they are designed to be more robust.
This is a slightly more sophisticated version of my earlier effort.
.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Aakash el 23 de Jun. de 2023
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Annotations en Help Center y File Exchange.

R2023a

### Community Treasure Hunt

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

Start Hunting!

Translated by