Make the plot not hit the 'ceiling'

5 visualizaciones (últimos 30 días)
JP
JP el 12 de Abr. de 2022
Comentada: JP el 12 de Abr. de 2022
So, in the graph that I attached, the line for the upper graph, for some reason is hidden in the 0.1 axis. If I stretch my eyes, I can see the blue slit. However, it makes it very hard to indentify it. I was wondering if there is a way to prop the axis up.
Note however, that this is runnin in a loop, so every graph have different boundaries. Thus I cant set a fixed limit for them.

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Abr. de 2022
In the general form where you might have a number of different objects plotted in the same axes, and the data is not necessarily starting from zero.
factor = 1/20;
ax = gca();
all_y = {findobj(ax, '-property', 'YData').YData};
maxy = max(cellfun(@max, all_y));
miny = min(cellfun(@min, all_y));
dylim = (maxy - miny)*factor
ylim( [miny - dylim, maxy + dylim]);
In practice a lot of the time this can be replaced entirely by something like
ylim([0 max(y)*1.05])
where y is your vector of y values when you drew a single line using plot(x,y)
Note: the above code will fail if the data contains infinite values.
  1 comentario
JP
JP el 12 de Abr. de 2022
Thank you very much! This worked perfectly!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots 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