pix2inches {iSPlot} | R Documentation

## Functions to perform conversions between different units of measurement

### Description

When a user interacts with a plot on a gtk device, the (x,y) location is returned in pixels, but to determine the point on the plot, we need the location to be stated in user coordinates. These functions, pix2inches and inches2usr, will do the conversion between pixels and inches, and inches and user coordinates, respectively.

### Usage

    pix2inches(x, y)
    inches2usr(x, y)
    getPixPerInch()
    devWidthPixels()
    devHeightPixels()
    devPixel()

### Arguments

`x` | the x location
`y` | the y location

### Details

MMPI is a constant, equal to 25.4. It is the number of millimeters per inch.

### Value

pix2inches and inches2usr both return a list with the following items.

`x` | the x location
`y` | the y location

pix2inches returns the (x,y) location in inches and inches2usr returns the (x,y) location in user coordinates.

### Author(s)

Robert Gentleman, Elizabeth Whalen

### See Also

`clickEvent`, `checkPoint`

### Examples

      if (interactive())
      {
        createControlWindow()
        # should load data through Open Data or Open File under the File menu
        data(USArrests)
        loadDFData(USArrests,"USArrests")
        # plotting the data should occur through Plot Data under
        # the Display menu
        # createView will call setActiveDF
        createView(type = "plotView", dataName = "USArrests",
                   plotType = "sPlotView", dfRows = 1:nrow(USArrests),
                   dfColumns = 1:2)

        Sys.sleep(1)
        # just randomly picked x=200 and y=300
        # normally the (x,y) location in pixels would be returned by
        # a gtk callback
        xyinch<-pix2inches(200,300)
        xi<-xyinch[[1]]
        yi<-xyinch[[2]]
        xyusr<-inches2usr(xi,yi)
      }

[Package iSPlot version 1.0.7 Index]