Home Comments Thread
New Thread

3 Comments

giscus-bot giscus-bot 2022-12-16 16:42:48
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?

yihui yihui 2022-12-16 16:42:50

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

giscus-bot giscus-bot 2022-12-16 16:42:49
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 ?

Sign in to join the discussion

Sign in with GitHub