xchange
transform real to pixel coordinates
Syntax
[x1, y1, rect] = xchange(x, y, dir)
Arguments
- x, y
two matrices of size
(n1, n2)
(coordinates of a set of points).- dir
a string, parameter used to specify the conversion type (See "Description" for details).
- x1, y1
two matrices of size
(n1, n2)
(coordinates of the set of points).- rect
a vector of size 4.
Description
After having used a graphics function, xchange
computes pixel coordinates from real coordinates and conversely,
according to the value of the parameter dir
:
"f2i"
(float to int) means real to pixel and
"i2f"
(int to float) means pixel to real.
x1
and y1
are the new
coordinates of the set of points defined by the old coordinates
x
and y
.
rect
is the coordinates in pixel of the rectangle
in which the plot was done: [upper-left point, width, height]
.
![]() | Coordinates in pixels are relative to the top-left point of graphical area in figure
(see axes_size in figure properties)
unlike uicontrols positions which are relative to the bottom-left
point of the graphical area (see examples below). |
Examples
Data conversions
With uicontrols
plot(-10:10, -10:10); sz = gcf().axes_size; // Used to change reference for positions xpos = [-10 -10 0 10 10]; ypos = [-10 10 0 -10 10]; for i = 1:size(xpos, "*") [xp, yp] = xchange(xpos(i), ypos(i), "f2i"); uicontrol("Style", "pushbutton", "Position", [xp, sz(2)-yp, 70, 20], "String", string(xpos(i)) + "/" + string(ypos(i))); end
Report an issue | ||
<< multiscaled plots | Graphics | Graphics export >> |