white space between title and plot in ioslides

狂风中的少年 提交于 2020-01-13 11:22:51

问题


I am using the default theme of ioslides for a presentation, and I have difficulties with arranging a plot on the slide.

I use the following code for the respective slide:

```{r crint1, fig.width = 7, fig.height = 5.5, fig.retina = NULL, fig.align="center"}
options(warn=-1)
load("path_to_data.RData")
ord <- order(cor.table$COR)
barplot(cor.table$COR[ord], names.arg=cor.table$group[ord],horiz=T
        , cex.name=.6, border=F, space=.3, col="gray30", 
        xlab="Correlation Coefficient", las=1)
  grid(NULL, NA, col="white", lty="solid", lwd=0.7)
    abline(v=mean(cor.table$COR), lwd=2, lty=2, col="red")
      text(mean(cor.table$COR), 1, "Average", cex=.8, col="red", pos=4)```

Which results in this:

Which is okay, but I would like the plot to start right below the title and extend more on the slide, so the names of the rows are readable and don't overlap.

I tried to play around with fig.height and fig.width, but they only extend the size of the plot and do not change the starting coordinates (which makes the plot extend beyond the slide).

Is there any way to reduce the white space below the title and use that margin to extend the plot? I assume I have to edit the CSS for that particular slide, I am just not sure how. Any help is appreciated.


回答1:


You can try the following:

Option 1:

Give your slide an id (here it is #slideID) and change the margins:

## Slide_title {#slideID} 
<style> 
  #slideID > p { 
    margin-top: -50px; 
  } 
</style>

Option 2:

Identify the slide with the plot (in my case its id is slide-1 and add the following styles:

<style>
    #slide-1 > p {
      margin-top: -50px;
    }
</style>

The plot is included with an img tag. And a paragraph p is wrapped around it. We want to move this one up by 50px. Additionally you can also alter the margin inside the plot to minimize the white space above the plotting area.

(For identifying the correct slide: open the presentation, display the slide with the plot and use the inspect element option inside of a browser (or the RStudio viewer) to view the source code)



来源:https://stackoverflow.com/questions/38590371/white-space-between-title-and-plot-in-ioslides

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!