如何在R Markdown中删除图形之间的空白

时间:2020-02-27 10:12:38

标签: html r r-markdown markdown

我想消除对象之间的长距离并将第二张图向左对齐。问题可能出在html结构中,我对此不太了解。我尝试使用fig.align = 'left',但不起作用。下面是我的示例:

enter image description here

# 
# ---
#   output: html_document
# ---
#   ### TITLE
#   <div class = "row">
#     <div class = "col-md-6">
#       ```{r echo=FALSE, message=FALSE, warning=FALSE}
#     library(knitr)
#     library(readxl)
#     library(tibble)
#     library(dplyr)
#     library(kableExtra)
#     library(plotly)
#     
#     dt <- mtcars[1:5, 1:6]
#     dt %>%
#       kable() %>%
#       kable_styling()
#     
#     ```
#     </div>
#       <div class = "col-md-6">
#       ```{r echo=FALSE, message=FALSE}
#     plot_ly(
#       x = c("giraffes", "orangutans", "monkeys"),
#       y = c(20, 14, 23),
#       name = "SF Zoo",
#       type = "bar",
#       height = 300, width = 400
#     )
#     ```
#     </div>
#       </div>
#       ### TITLE
#       <div class = "row">
#       <div class = "col-md-6">
#       ```{r echo=FALSE, message=FALSE}
#     plot_ly(
#       x = c("giraffes", "orangutans", "monkeys"),
#       y = c(20, 14, 23),
#       name = "SF Zoo",
#       type = "bar",
#       height = 300, width = 400
#     )
#     ```
#     </div>
#       <div class = "col-md-6">
#       ```{r echo=FALSE, message=FALSE}
#     dt <- mtcars[1:5, 1:6]
#     dt %>%
#       kable() %>%
#       kable_styling()
#     ```
#     </div>
#       </div>   

1 个答案:

答案 0 :(得分:2)

您可以通过将style标签添加到它所在的div中来向下移动表格以减小间隙:

<div class = "col-md-6" style = "margin-top:60px;">

并执行类似于保存情节的div的操作:

<div class = "col-md-6" style = "margin-left:-60px;">

得出以下结果:

enter image description here

您可以通过这种方式添加任何其他喜欢的CSS样式调整,以移动元素,调整元素的大小/颜色等。