【问题标题】:Italicize the caption in ggplotly figure斜体ggplotly图中的标题
【发布时间】:2020-11-18 12:21:22
【问题描述】:

我不确定为什么标题没有改变,我可能使用了错误的功能。这是一个例子:

我的数据框moment.curve:

moment.curv <- structure(list(row = 1:5, Curvature = c(
  0, 0.001805, 0.004512,
  0.008121, 0.0126
), Moment = c(
  0, 192.0442, 242.8942, 256.6455,
  258.1099
)), class = "data.frame", row.names = c(NA, -5L))

我使用以下代码来创建情节:

plot.moment.curv <- ggplot(moment.curv) +
 aes(x = Curvature, y = Moment) +
 geom_line(size = 1L, colour = "#0c4c8a") +
 labs(x = "bla", y = "bla") + theme_classic()

我使用以下内容创建 ggplotly 交互式绘图,请记住,我想保留这种格式,即在 ggplot 中制作原始绘图,然后使用 ggplotly 将其转换为交互式绘图。我正在创建的实际数字要复杂得多,这使得过程更容易。

ggplotly(
  p = ggplot2::last_plot(),
  width = NULL,
  height = NULL,
  tooltip = "all",
  dynamicTicks = FALSE,
  layerData = 1,
  originalData = TRUE,
) %>% 
 layout(margin = list(b=130,t=100), annotations = 
 list(x = 1, y = -0.4, text = "THE CAPTION", 
      showarrow = F, xref='paper', yref='paper', 
      xanchor='right', yanchor='auto', xshift=0, yshift=0,
      font=list(size=15,fontfacet="italic"))
 )

谢谢!

【问题讨论】:

    标签: r ggplot2 ggplotly


    【解决方案1】:

    要更改字体,您必须使用 HTML 标记,即使用 text = "&lt;i&gt;THE CAPTION&lt;/i&gt;" 将标题变为斜体。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-19
      • 2016-02-08
      • 2020-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-24
      • 2017-12-24
      相关资源
      最近更新 更多