简体   繁体   中英

How to get the min x, max x, min y and max y of a certain figure in MATLAB?

I want to design a function, which can add text in the right corner of the figure according to user's input parameter ('UpperLeft', 'UpperRight', 'LowerLeft', 'LowerRight'). I implement it in the following way: If I want to add text in the upper left corner, I firstly get the min x and max y of the axis in the figure, then use text(min_x, max_y, 'text') to draw it. But I don't know what function can get the min x and max y. And if there any other way to implement the function I want?

x = 3*sin(linspace(0,10,100));
figure
plot(x)
xl = xlim
yl = ylim
% upper left (ish), you'll want to position the text a little down and to
% the right depending on the dimensions of the plot
text(xl(1), yl(2), 'text')

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM