Dynamically Selecting Points Using R | /en/2008/10/dynamically-selecting-points-using-r/
Dynamically Selecting Points Using R
https://yihui.org/en/2008/10/dynamically-selecting-points-using-r/
https://yihui.org/en/2008/10/dynamically-selecting-points-using-r/
Guest *Ra* @ 2009-06-22 16:34:19 originally posted:
Do you think it would be possible to create an html image-map in a similar way ?
I'm very newbie R guy; I'm confortable with Ruby, Java or C, however I need to create an Image-map for a R plot. Any clue?
I guess it's almost impossible to select points and mark them out in a bitmap image (as I did in the above example), but to create an HTML image-map is another thing. An image map is just some pure text HTML code, thus you can generate them with a text-writing function such as cat() or writeLines(). For example,
cat(sprintf("<img src="file://%s" usemap="#mymap" border="0" />n
<map name="mymap">n
<area shape="rect" coords="30,20,70,50" href="http://yihui.name">n
</map>",
normalizePath(file.path(R.home("doc"), "html", "logo.jpg"))),
file = "myRmap.html")
# see the HTML file "myRmap.html" under getwd()
What you need to do is to replace the coordinates in the area tag with what you want.
Originally posted on 2009-06-22 17:25:47
Guest *Ra* @ 2009-06-22 20:59:27 originally posted:
Hello Yihui,
ok that's the scaffold for a generic image-map. Suppose I want to map every point R plots. The coordinates for the map are relative to the global image size (the output image), is it possible to get from R the image coordinates it computes for evey point ?
Guest *Ra* @ 2009-06-22 21:12:33 originally posted:
I found this:
http://onertipaday.blogspot.com/2009/01/map-coordinates-to-actual-pixel.html
seems to be what I was looking for.
OK, then you can use the circle shape and coordinates returned by grconvertX() and grconvertY() to create image maps in your graph. ;-)
Originally posted on 2009-06-23 12:02:44
Sign in to join the discussion
Sign in with GitHub