You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Quarto的R环境下让Plotly图形的fig-cap标题正常显示?

在Quarto中为Plotly图形添加下方题注的解决方案

针对你遇到的fig-cap不显示的问题,以下是几种可行的解决方式:

方法1:确保Quarto版本与块选项正确

Quarto新版本已支持为Plotly等交互式图形添加题注,只需确认代码块选项设置正确,并升级Quarto到最新版本:

#| fig-cap: "*Caption here*"
#| column: page-inset-right
#| fig-align: center

library(plotly)
fig <- plot_ly(midwest, x = ~percollege, color = ~state, type = "box")
fig

注意题注文本的Markdown格式要正确(比如斜体用成对的*),同时确保输出格式(如HTML)支持交互式图形的题注渲染。

方法2:手动添加格式化题注

如果自动题注仍不生效,可在代码块后直接添加自定义样式的题注,对齐方式和字体大小可按需调整:

#| column: page-inset-right

library(plotly)
fig <- plot_ly(midwest, x = ~percollege, color = ~state, type = "box")
fig

Caption here

方法3:用quarto::as_figure()包裹图形

通过quarto包的as_figure()函数将Plotly图形转换为支持题注的对象:

#| column: page-inset-right

library(plotly)
library(quarto)

fig <- plot_ly(midwest, x = ~percollege, color = ~state, type = "box")
as_figure(fig, caption = "*Caption here*")

内容的提问来源于stack exchange,提问作者Thomas Speidel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 05:07:12