使用DiagrammeR和Xaringan演示将图形居中
使用DiagrammeR和Xaringan演示将图形居中,r,r-markdown,diagrammer,xaringan,R,R Markdown,Diagrammer,Xaringan,fig.align='center'在Xaringan演示文稿中不会居中Diagrammer绘图。有什么想法吗 见下面的reprex --- title: "Title" encoding: "UTF-8" output: xaringan::moon_reader: self_contained: true lib_dir: libs css: [default] nature: highlightStyl
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
标记可以工作,应该是一个可行的解决方案
只需将其添加到R代码之前,并在结尾处结束。
这可能不优雅(用CSS术语),但它可以工作
# TITLE
.center[Some text]
<center>
```{r title, out.height='50%', fig.align='center'}
ETC.
</center>
#标题
.center[一些文本]
```{r title,out.height='50%',fig.align='center'}
等
这似乎适用于您的示例——尽管下面的注释可能对颜色有限制。但答案是FOMJYS有效。