使用图形注释字体粗体

时间:2018-04-27 17:14:48

标签: r fonts plotly

我想将annotation添加到由scatter的{​​{1}}包生成的R地块中,并将文字以粗体显示

我正在尝试:

plotly

给出了: enter image description here

尝试将library(plotly) library(dplyr) set.seed(1) df <- data.frame(x=rnorm(10),y=rnorm(10)) plotly::plot_ly(x =~ df$x, y =~ df$y,marker = list(size=12), type = 'scatter',mode = "markers") %>% plotly::add_annotations(text=1:10,showarrow=T,arrowhead=1,x=df$x,y=df$y,font=list(size=10)) 添加到face="bold"规范font

list

没有真正改变任何事情: enter image description here

所以问题是如何让文本注释以粗体显示。

P.S。 在我的真实数据中,我想注释点的集群,因此注释作为一个单独的层。

1 个答案:

答案 0 :(得分:3)

只需输入您的文字为HTML,如下:

plotly::plot_ly(x =~ df$x, y =~ df$y,marker = list(size=12), type = 'scatter',mode = "markers") %>%
  plotly::add_annotations(text=sprintf("<b>%s</b>", 1:10),showarrow=T,arrowhead=1,x=df$x,y=df$y,font=list(size=10))
相关问题