setting y axis to specific values
Show older comments
UPDATE FROM MY QUESTION BELOW: I should have done a bit of research before posting. Don't know why i didn't assume matlab would have an automatic way to link axes. I have used the linkaxes function to link the left and right axes together and it worked. However, i still would like to apply the (-50,50) as my standard y min and y max. So for example i have the billateral muscles that are linked and have y min and ymax values as (-20,20).
I have a tiled plot and the two plots in question are tiles 1 and 2 with corresponding ax1 and ax2 variables:
% Tile 1
ax1=nexttile
p1=plot(ChannelTitle,LUTbandpass);
xlim([xlim1 xlim2])
% Tile 2
ax2=nexttile
p2=plot(ChannelTitle,RUTbandpass);
xlim([xlim1 xlim2])
linkaxes([ax1 ax2],'y')
The column vectors LUTbandpass and RUTbandpass are what i want to find the max and min of and figure out if either is below the +/- 50 and if so, want to set the y axis to (-50,50)
Hope that makes sense.
Thank you
END EDIT
Hi,
I am curious if my below code can be made more efficent/streamlined. I have two EMG plots from a muscle, one from the right side and one from the left. I want my code to look at the y max and min of both plots and determine which is higher and then set that scale for both plots.
I currently have this for the y max and y min determination:
%ymax
if max(left)<50 && max(right)<50
ymax=50
elseif max(right)>max(left)
ymax=max(right)+.15*(max(right))
else
ymax=max(left)+.15*(max(left))
end
%ymin
if min(left)>-50 && min(right)>-50
ymin=-50
elseif min(right)<min(left)
ymin=min(right)+.15*(min(right))
else
ymin=min(left)+.15*(min(left))
end
I have a set of 8 billateral muscles and don't want to repeat this code over and over.
Once i have the ymax and ymin values i will use them in my overall plot with code:
ylim([ymin ymax])
Any help would be apprecated!
Thank you in advance
2 Comments
Ines Shekhovtsov
on 4 Jan 2023
Edited: Ines Shekhovtsov
on 4 Jan 2023
Voss
on 6 Jan 2023
@Ines Shekhovtsov: Have you seen my answer? Do you think it will work for you? Is there anything that doesn't make sense about it?
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects 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!