[R] insert hyperlink into svg graphic
Boris Steipe
bor|@@@te|pe @end|ng |rom utoronto@c@
Tue Mar 7 20:09:12 CET 2023
This was actually the first thing that ChatGPT debugged for me.
The issue was that I was able to click on the link when I displayed the raw SVG in the browser (you can use that to test whether the syntax is even correct), but not when the svg displays inside a html page with the <img ...> tag.
ChatGPT correctly identified the issue and suggested a solution using <object ...> tags instead.
Here's how that would work:
<object data="temps.svg" type="image/svg+xml" alt="Image description TK">
<p>Your browser does not support the <object> tag.</p>
</object>
(Most browsers support the object tag: see https://caniuse.com/mdn-html_elements_object )
Cheers,
Boris
> On 2023-03-07, at 10:33, Bert Gunter <bgunter.4567 using gmail.com> wrote:
>
> Perhaps this thread on stackoverflow (from a search on "include hyperlink
> in svg graphic") may be of use:
>
> https://stackoverflow.com/questions/41970535/a-hyperlink-in-svg-use
>
> Cheers,
> Bert
>
> On Tue, Mar 7, 2023 at 12:34 AM Rusty Travis <rusytravis19 using gmail.com> wrote:
>
>> Greetings,
>>
>> I am creating plots of weather data and wish to include a link to the
>> data source into a title() object in the plot. My syntax must be wrong
>> though, as the hyperlink doesn't display, just the text and tags.
>>
>>> svg("/tmp/temps.svg", width=9, height=6)
>>> #plot created here
>>> title(sub="produced by Rusty Travis \nusing data from <a
>> xlink:href=https://www.ncei.noaa.gov/cdo-web/>test</a> ", line=-1.5,
>> adj=1)
>>> dev.off()
>>
>> The goal is to create a hyperlink of the word "test" in the above
>> example. What is the correct syntax, please?
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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