Search code examples
matlabgraphplotbounds

how to plot graphic with the same Y bound


I have to plot graphics and compare them but it's misleading because of different y-axis upper bounds for each of them (they are all positive values). Anyway I'm doing a cycle like this:

 %% check for data files
 for i=1:length(files)
    load
    plot(x,y)
 end

I need to change my code if I want to save the maximum upper bound on y.

 %% check for data files
 for i=1:length(files)
    load
    %% compare upper bounds and get the maximum
 end
 %% plot cycle

But then how can I use this value to plot comparable but separated graphics. I can't plot them in only one figure because they are many. Also tell me If you think of a possible optimization for my task.


Solution

  • ylim is what you are looking for, but if i understood you right you might also want to look at linkaxes.