Borrar filtros
Borrar filtros

Break in the axis

767 visualizaciones (últimos 30 días)
Niles Martinsen
Niles Martinsen el 2 de Jul. de 2012
Editada: Walter Roberson el 4 de Mayo de 2024
Hi
I have a plot of data points (x, y). The issue is that one of the first data points has a very large amplitude, whereas the rest of the data points have very small magnitudes. So what I thought that I wanted to do is to make a "cut" in the y-axis, such that it goes from 0..1 and then skips to 100..105. Perhaps with a mark such as this "----//----" in between.
Is that possible in MatLAB?
Best, Niles.
  2 comentarios
Daniel Shub
Daniel Shub el 1 de Ag. de 2013
Lea
Lea el 4 de Mayo de 2024

Iniciar sesión para comentar.

Respuesta aceptada

Thomas
Thomas el 2 de Jul. de 2012
Editada: Thomas el 2 de Jul. de 2012

Más respuestas (4)

yanan LIU
yanan LIU el 29 de Feb. de 2020
There is no direct function as I know.
But you can try to plot the double line on your figure.
for example,
x=1:10;
y=sin(x);
plot(x,y,'k*-','LineWidth',1.5,'MarkerSize',8);
axes('Position',[.1 .78 .05 .05]);
px=[1 5];
py1=[1 2];
height=1;
py2=py1+height;
plot(px,py1,'k','LineWidth',2);hold all;
plot(px,py2,'k','LineWidth',2);hold all;
fill([px flip(px)],[py1 flip(py2)],'w','EdgeColor','none');
box off;
axis off;
Then you can get the follow figure.

Peter
Peter el 1 de Ag. de 2013

Philippe Lebel
Philippe Lebel el 22 de Ag. de 2018
Editada: Walter Roberson el 4 de Mayo de 2024
  1 comentario
Walter Roberson
Walter Roberson el 22 de Ag. de 2018
That's what Thomas suggested 6 years ago.

Iniciar sesión para comentar.


Lea
Lea el 4 de Mayo de 2024
Building on Yanan LIU's contribution, I explained it more and this is for a break in the x axis.
%Here, Yanan allows us to choose the location of the break. In Yanan's
%code, it is on the y axis, here it is on the x axis (done by changing the
%two first numerical values). Axes basically creates a new very small plot
%(0.05*0.05) at (0.8,0.175).
axes('Position',[.8 .175 .05 .05]);
%this code forms the rectangle for the break sign on the axis itself. px
%defines the x values of the rectangle, py1 from the bottom and py2 from
%the top. height specifies the height of the rectangle.
px=[1 2];
py1=[1 2];
height=0.5;
py2=py1+height;
%'k', the black outer lines are drawn, one with each plot.
plot(py1,px,'k','LineWidth',2);hold all;
plot(py2, px, 'k','LineWidth',2);hold all;
%%Here, the rectangle is filled with white, 'w'
fill([py1 flip(py2)],[px flip(px)],'w','EdgeColor','none');
box off;
%remove the axis labels for the small axes we made, so that you only have
%the lines and the white filling
axis off;

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by