簡體   English   中英

在 Plotly 中添加腳注

[英]Adding footnote in Plotly

我正在嘗試向使用 Plotly 繪制的圖表添加星號腳注。這是我的代碼:

library(plotly)

fig <- plot_ly(
  x = c("giraffes", "orangutans", "monkeys"),
  y = c(20, 14, 23),
  name = "SF Zoo",
  type = "bar"
)

fig

現在我想在“長頸鹿*”上加一個星號,然后在這個欄 plot 下面給出一些額外的解釋,比方說: Note: * The tallest animal

您可以使用layout(annotations)將“標題”添加到Plotly

library(plotly)

plot_ly(
  x = c("giraffes*", "orangutans", "monkeys"),
  y = c(20, 14, 23),
  name = "SF Zoo",
  type = "bar"
) |> 
  layout(annotations = 
           list(x = 0, y = -0.1, 
                text = "Note: * The tallest animal.", 
                showarrow = F, 
                xref='paper', 
                yref='paper')
  )

情節標題

暫無
暫無

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

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