簡體   English   中英

在R Plotly中將超鏈接插入軸標題

[英]Inserting hyperlinks into axis titles in R Plotly

我希望使用R將超鏈接嵌入到圖形圖的x軸上。我想要實現的一個非常好的例子是: https ://help.plot.ly/adding-HTML-and- 鏈接到圖表/#鏈接,文本和HTML功能於圖表

但是,當我在繪圖軸標題注釋中添加鏈接時,它會添加具有正確格式的文本,但沒有超鏈接本身(即,我無法導航到繪圖中的鏈接)。

我已經嘗試刪除任何多余的東西(即,刪除選項以在另一個選項卡中打開鏈接 - target ='_ blank')。

這是一個例子:

  library(plotly)
  data(mtcars)
  p <- plot_ly() %>%
    add_trace(data = mtcars, 
              x = ~cyl, y = ~mpg, 
              type = 'scatter',
              mode = 'lines') %>%
    layout(autosize = T,
           title = "Test",
           xaxis = list(title = "<a href = https://www.nytimes.com/>The NY TIMES</a>"))

我期待這個情節,除了帶有我到網站的實際鏈接。 非常感謝您的幫助!

你只是忘記了鏈接周圍的一些引用。

這應該工作正常:

library(plotly)

data(mtcars)
p <- plot_ly() %>%
  add_trace(data = mtcars, 
            x = ~cyl, y = ~mpg, 
            type = 'scatter',
            mode = 'lines') %>%
  layout(autosize = T,
         title = "Test",
         xaxis = list(title = "<a href = 'https://www.nytimes.com/'>The NY TIMES</a>"))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM