我在 knitr 中使用 googleVis,通常可以使用 来居中绘图fig.align="center"
,但是,这似乎不适用于 googleVis 绘图。如何将 googleVis 图居中在页面中间?
这是 MWE Rmd 文件
```{r setup, include=FALSE}
# set global chunk options
opts_chunk$set(cache=TRUE)
```
------
## Page 1
```{r echo = FALSE, results="asis", fig.align="center", messages=FALSE}
dat <- data.frame(party=c("CDU", "FDP", "CSU", "SPD",
"The Left", "The Greens"),
members.of.parliament=c(193, 93, 44,
146, 76, 68))
library(googleVis)
## Doughnut chart - a pie with a hole
doughnut <- gvisPieChart(dat,
options=list(
width=500,
height=500,
slices="{0: {offset: 0.2},
1: {offset: 0.2},
2: {offset: 0.2}}",
legend='none',
colors="['black','orange', 'blue',
'red', 'purple', 'green']",
pieSliceText='label',
pieHole=0.5),
chartid="doughnut")
print(doughnut, "chart")
```
------
## Page 2
```{r echo = FALSE, fig.align="center"}
plot(1:10, 1:10)
```