# Breaking the axis of plots (without external packages etc)

2 visualizaciones (últimos 30 días)
HC98 el 4 de Jun. de 2023
Respondida: Star Strider el 4 de Jun. de 2023
Is there a simple way to break the axis of my plot without falling a function from the mathworks public package repository etc? I.e. hard code it in my script?
##### 2 comentariosMostrar NingunoOcultar Ninguno
Matt J el 4 de Jun. de 2023
What does it mean for an axis to be "broken"?
HC98 el 4 de Jun. de 2023
To chop out a section

Iniciar sesión para comentar.

### Respuestas (1)

Star Strider el 4 de Jun. de 2023
I am not certain what you want, so I decided to give this a shot just out of interest —
x = [linspace(0, 10, 11); linspace(20, 30, 11)]; % Create Data
y = [sin(x(1,:)*2*pi*0.09); sin(x(2,:)*2*pi*0.05)]; % 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;
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
subplot(1,2,2)
plot(x(2,:), y(2,:)) % Plot Second Group
grid
Ax2 = gca;
Ax2.YAxis.Visible = 0; % Turn Off Y-Axis
Add axis labels and other options (this may require separate text calls to put them in the correct positions). Use sgtitle to add a unified title.
.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Line Plots 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