pix2inches {iSPlot} | R Documentation |
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.
pix2inches(x, y) inches2usr(x, y) getPixPerInch() devWidthPixels() devHeightPixels() devPixel()
x |
the x location |
y |
the y location |
MMPI is a constant, equal to 25.4. It is the number of millimeters per inch.
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.
Robert Gentleman, Elizabeth Whalen
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) }