Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
dismo中使用knitr的绘图前面带有空白_R_Rstudio_R Markdown - Fatal编程技术网

dismo中使用knitr的绘图前面带有空白

dismo中使用knitr的绘图前面带有空白,r,rstudio,r-markdown,R,Rstudio,R Markdown,我在RStudio中使用knitr和dismo包。尽管我可能会尝试,但我无法让使用gmap创建的绘图立即显示在R标记中的文本之后 这是一个截图 这里是一个最小的R标记,可以用来重新创建它。您需要安装三个引用的软件包 我使用RStudio,在这个环境中执行knitr命令 --- title: "gmap" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) library

我在RStudio中使用knitr和dismo包。尽管我可能会尝试,但我无法让使用gmap创建的绘图立即显示在R标记中的文本之后

这是一个截图

这里是一个最小的R标记,可以用来重新创建它。您需要安装三个引用的软件包

我使用RStudio,在这个环境中执行knitr命令

---
title: "gmap"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(dismo)
library(rgdal)
library(XML)
```
The plot should follow this text
```{r plot, fig.align='left', echo=FALSE, message=FALSE}
g = gmap('Australia')
plot(g)
```
and precede this. Try as I might, there is white space between the start text and the image which I cannot get rid of.
我无法用knitr指令控制图像的高度,谷歌也没有给出明显的答案。有没有人见过这一点,并可以提供任何建议


编辑:我有一个变通方法,可以打印到png文件,然后将其包括在内。这避免了问题,但很笨重。

添加
fig.keep='last'
在生成映射的块的头中。在调用函数
gmap()
的过程中,似乎生成了两个数字。如果查看html页面的源代码,可以看到这一点。我不知道何时何地生成空白图像(KNITE),GAMP(),??)。但是,选项
fig.keep='last'
应该只解决保留第二个图形(地图)的问题

```{r plot, echo=FALSE,results='asis', fig.keep='last', fig.align='right'}
g = gmap('Italia')
plot(g)
```