GetDeviceXY — Translate world coordinates into device coordinates
list($x, $y) = $plot->GetDeviceXY($x_world
,$y_world
)
GetDeviceXY
translates values in
world coordinates into
values in device coordinates.
This is useful if you want to annotate a plot with text or graphics
positioned relative to specific data values. Given the coordinates of a
point in the coordinate space of your data values, this function returns
the pixel coordinates of that point in the image.
$x_world
The X coordinate to translate from world coordinates.
$y_world
The Y coordinate to translate from world coordinates.
Returns an array of two values ($x, $y) in device coordinates which correspond to the world coordinate parameters.
This function only works after scaling factors have been established, which happens in DrawGraph. So it can only be used in two cases:
From a drawing callback (see Section 4.4, “Callbacks”) - that is, a callback whose name starts with 'draw'.
If SetPrintImage(False) is used to disable automatic
output of the image file, then GetDeviceXY()
can be
used after DrawGraph returns.
GetDeviceXY()
will fail with an error message if it
is called before scaling is set up.
If the world coordinates represent a point that is not visible on the plot, the returned device coordinates will be outside the plot area, or even outside the image area.
To see how this can be used in callbacks, see Section 4.4.5, “Using Callbacks to Annotate Plots”.
Because there are no valid world coordinates for pie charts,
GetDeviceXY()
does not work with pie charts.
This version of the manual was produced for the
PHPlot Sourceforge project web service site, which requires the logo on each
page.
To download a logo-free copy of the manual, see the
PHPlot project downloads
area.