r语言 - 更改 ggplotly 对象内文本注释的字体大小



>我有下面的数据帧:

df <- data.frame(result=floor(rnorm(1000, 100, 20)))    

我创建了一个带有注释的 ggplotly 直方图。我想知道如何更改paste()内的字体大小。

require(scales)
library(ggplot2)
library(plotly)
df <- data.frame(result=floor(rnorm(1000, 100, 20)))   
ggplotly(ggplot(df)+
geom_histogram(aes(result, fill = (result<=80 | result > 95)),
binwidth = 5, center = 2.5, color = "black") +
scale_fill_manual(values=c("darkblue", "lightblue"), guide = F) +
labs(y = "Frequency", x = "Result") + scale_y_continuous(labels = comma)+
theme_classic(base_size = 16))%>%
layout(annotations = list(x = 140, y = 100, text = paste("Mean:","Num"), showarrow = T))

我用这个答案来修复这个 https://plot.ly/r/text-and-annotations/

最新更新