在plotly上缩放时保持文本大小不变[R]

在plotly上缩放时保持文本大小不变[R],r,annotations,plotly,figure,r-plotly,R,Annotations,Plotly,Figure,R Plotly,对于R上的老年人来说,这可能很简单,但我无法通过精心编制的文档和论坛找到任何解决方案。基本上,即使用户在整个图中放大/缩小,示例文本的大小(如下面的代码:“示例文本”)也应该保持在相同的大小,而不只是放大和缩小该文本部分,包括类似于水印思想的位置等。不应完全禁用图形的放大/缩小功能,仅限于此文本。有什么建议吗? 提前谢谢 library(plotly) density <- density(diamonds$carat) fig <- plot_ly(x = ~density$x

对于R上的老年人来说,这可能很简单,但我无法通过精心编制的文档和论坛找到任何解决方案。基本上,即使用户在整个图中放大/缩小,示例文本的大小(如下面的代码:“示例文本”)也应该保持在相同的大小,而不只是放大和缩小该文本部分,包括类似于水印思想的位置等。不应完全禁用图形的放大/缩小功能,仅限于此文本。有什么建议吗? 提前谢谢

library(plotly)

density <- density(diamonds$carat)

fig <- plot_ly(x = ~density$x, y = ~density$y, type = 'scatter', mode = 'lines', fill = 'tozeroy')
fig <- fig %>% layout(xaxis = list(title = 'Carat'),
                      yaxis = list(title = 'Density'),
                      annotations=list(text="Example Text", "showarrow" = F, font=list(size = 40))
                      )
fig
library(plotly)
密度我意识到yref=“paper”和xref=“paper”允许我们指定始终相对于绘图的位置。y=1表示绘图顶部,y=0表示绘图底部。类似地,x=1表示绘图的右侧,x=0表示绘图的左侧。见详情。基于此,我对代码进行了如下修改。这是完美的工作,因为在和

修改代码

library(plotly)

density <- density(diamonds$carat)

fig <- plot_ly(x = ~density$x, 
               y = ~density$y, 
               type = 'scatter', 
               mode = 'lines', 
               fill = 'tozeroy')
fig <- fig %>% layout(xaxis = list(title = 'Carat'),
                      yaxis = list(title = 'Density'),
                      annotations=list(text="Example Text", 
                                       xref = "paper",
                                       yref = "paper",
                                       opacity = 0.4,
                                       "showarrow" = F, 
                                       font=list(size = 40)
                                       )
                      )
fig
library(plotly)
密度