gpt4 book ai didi

r - 使用 DiagrammeR 和 Xaringan 演示文稿居中图形

转载 作者:行者123 更新时间:2023-12-05 02:06:14 25 4
gpt4 key购买 nike

fig.align='center' 不会在 Xaringan 演示文稿中将 Diagrammer 图居中。有什么想法吗?

请参阅下面的 reprex。

---
title: "Title"
encoding: "UTF-8"
output:
xaringan::moon_reader:
self_contained: true
lib_dir: libs
css: [default]
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
ratio: "16:9"
---

exclude: true

```{r setup, include=FALSE}
knitr::opts_chunk$set(
echo = FALSE,
warning=FALSE,
message=FALSE,
comment = NA)
```

---

# TITLE

.center[Some text]

```{r title, out.height='50%', fig.align='center'}

DiagrammeR::grViz("

digraph {

# a 'graph' statement
graph [layout = twopi, overlap = false]

# several 'node' statements
node [shape = circle,
fontname = 'Century Gothic',
style = filled,
color = white,
fontcolor = white]

node [fillcolor = steelblue]
Hello; How; You; Doing

node [label =
'Im a reprex']
reprex1

node [label =
'im also a reprex']
reprex2

node [fillcolor = coral,
label =
'thats weird,
im a reprex too!']
reprex3

edge [color = grey]
reprex1 -> {Hello; How; You; Doing; reprex2; reprex3}
reprex3 -> reprex1

}
")
```

.center[yet another text]

最佳答案

我刚试过:HTML <center>标签有效,应该是一个可行的解决方案。

只需将其添加到R代码之前并在末尾关闭即可。这可能不够优雅(在 CSS 术语中),但它确实有效!

# TITLE

.center[Some text]

<center>

```{r title, out.height='50%', fig.align='center'}
ETC.

</center>

关于r - 使用 DiagrammeR 和 Xaringan 演示文稿居中图形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62855840/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com