[R] adding hyperlinked text to pdf plot

David M. Schruth dschruth at u.washington.edu
Wed Dec 7 19:45:35 CET 2011


Hi Justin,

It sounds like you might be able to use the 'hyperplot()' function (in 
the 'caroline' package) for creating an html imagemap around your 
figure.  This is assuming all that you want to do is interactivate a 
2-dimensional scatter plot.  You'd also lose PDF-pagination but the 
auto-tabbing of most browsers from each independent hyperplot() call 
should help you stay organized.

Say you use hyperplot() like so:

----------------------------------------------------------------
library(caroline)

chr1 <- data.frame(pos=1:1000, cov=rnorm(1000,10,1), 
url=paste('http://my.genome.org/id=',1:1000,sep=''))
hyperplot(x='pos',y='cov', annout=chr1, link='url',
           xlab='position', ylab='coverage')

chr2 <- data.frame(pos=1:1000, cov=rnorm(1000,10,1), 
url=paste('http://my.genome.org/id=',1:1000,sep=''))
hyperplot(x='pos',y='cov', annout=chr2, link='url',
           xlab='position', ylab='coverage')
#chr3 <-
#...etc...
----------------------------------------------------------------

With this approach you'd have each chromosome on a different tab.

Cheers,

Dave




On 12/5/2011 12:20 PM, Yihui Xie wrote:
> Sorry I experimented with tikzDevice using \href{}{} but failed.
>
> You can probably try the old image hotspot technique in HTML. I
> remember someone did this before in R, but I cannot find the link to
> the work now. The key is your need to use the two functions grconvertX
> and grconvertY.
>
> Regards,
> Yihui
> --
> Yihui Xie<xieyihui at gmail.com>
> Phone: 515-294-2465 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 2215 Snedecor Hall, Ames, IA
>
>
>
> On Mon, Dec 5, 2011 at 2:10 PM, Justin Fincher<fincher at cs.fsu.edu>  wrote:
>> For example, say I am plotting some data that is genomic and therefore
>> maps to a specific locus on the human genome, like a gene.  I was
>> hoping to have the title of the plot display the gene name, but have
>> it be a link so that clicking on it would take you to those
>> coordinates on a public browser, like USCS's genome browser.  So
>> basically, I was hoping to have text in a plot generated by R function
>> as a normal html-style link.
>>
>> - Fincher
>>
>>
>> On Mon, Dec 5, 2011 at 14:09, Yihui Xie<xie at yihui.name>  wrote:
>>> It seems I missed the context of this post -- who is "you", and what
>>> is "something other than the URL"?
>>>
>>> I feel the tikzDevice package should be an option for the task.
>>>
>>> Regards,
>>> Yihui
>>> --
>>> Yihui Xie<xieyihui at gmail.com>
>>> Phone: 515-294-2465 Web: http://yihui.name
>>> Department of Statistics, Iowa State University
>>> 2215 Snedecor Hall, Ames, IA
>>>
>>>
>>>
>>> On Mon, Dec 5, 2011 at 12:39 PM, Justin Fincher<fincher at cs.fsu.edu>  wrote:
>>>> Howdy,
>>>>    I have read that if you put a URL in the text of a plot being saved
>>>> into pdf, the result is a functional hyperlink. I am interested in
>>>> having text in a plot that is linked to a URL, but I would like the
>>>> text to be something other than the URL. Is this possible? Thank you.
>>>>
>>>> - Fincher
>>>>
>>>> ______________________________________________
>>>> R-help at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>> --
>>> This message has been scanned for viruses and
>>> dangerous content by MailScanner, and is
>>> believed to be clean.
>>>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list