Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

white space between title and plot in ioslides

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:

link to image

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.

like image 716
Erdne Htábrob Avatar asked Jul 26 '16 12:07

Erdne Htábrob


1 Answers

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.

enter image description here

(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)

like image 162
Martin Schmelzer Avatar answered Sep 25 '22 10:09

Martin Schmelzer