Clear Filters
Clear Filters

Centering different yaxis plots at the same point

2 views (last 30 days)
Hi. I am trying to plot arrays of which have different y ranges. For example, array1 could range from -1 to 1 while another may range from 1 to 3. An example of the code is as follows:
for j = 1:30
plot(array(1:shut(j),j));
end
As you see, each array (j) begins at a different y value. Is there a way I can have all of these arrays begin at the same y value graphically without altering the arrays themselves? The actual value of the y would not matter so long as the relative ranges are the same. Thanks in advance!

Accepted Answer

Star Strider
Star Strider on 18 May 2020
Subtract the first y-value from each one and they all should begin at 0.
Example —
x = sort(rand(5, 20),2);
y = randi(20, 5, 20);
figure
hold on
for k = 1:size(x,1)
plot(x(k,:), y(k,:))
end
grid
figure
hold on
for k = 1:size(x,1)
plot(x(k,:), y(k,:)-y(k,1))
end
grid
.

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!