Question: Using BiocStyle with plotly
gravatar for Lluís Revilla Sancho
23 months ago by
European Union
Lluís Revilla Sancho470 wrote:

I want to use the BiocStyle and plotly together for an html output. However, plotly (or better ggplotly) doesn't seem to get the the size of the image from the css. Still I want to keep the visualizations I make the more similar (in size) to those from BiocStyle.

Which are the width and height of fig.wide and fig.small ?


Looking at the source I found something (related ?) in knitr_options.R in the fig.width function:

"smallfigure" = 5,
"figure*" = 10,
"figure" = 8

But I am not sure if the second one is the width of the wider figure.

ggplot2 biocstyle plotly • 460 views
ADD COMMENTlink modified 23 months ago by Andrzej Oleś720 • written 23 months ago by Lluís Revilla Sancho470
Answer: Using BiocStyle with plotly
gravatar for Andrzej Oleś
23 months ago by
Andrzej Oleś720
Heidelberg, Germany
Andrzej Oleś720 wrote:

Hi Lluís,

thanks for your feedback! I had a look into sizing of plotly::ggplotly output and it seems that this is a more general issue which is present also for regular html_document format,  and not something specific to BiocStyle. The thing is that the produced output has fixed size and does not scale to fit into respective CSS containers. There doesn't seem to be an easy user-side solution to this. I need to look more deeply into it, so stay tuned.

For now, use the width and height arguments to ggplotly to specify some reasonable size in pixels.


ADD COMMENTlink modified 23 months ago • written 23 months ago by Andrzej Oleś720

Yes, for me it is fine to use width and height argument of ggplotly, but which measures should I use to mimic the fig.wide = TRUE?

ADD REPLYlink written 23 months ago by Lluís Revilla Sancho470

The actual width of BiocStyle's figures produced by the fig.wide = TRUE code chunks is 648 pixels, so you could use the rounded up value of 650 pixels. For the regular and small figures the width is 518 and 323 pixels, respectively. The height of the figures depends on their aspect ratio, with the default set such that the height of the different types of figures is the same and matches roughly 325 pixels. This corresponds to the 1:2 aspect ratio of the wide figures.

There is one more quirk in getting the ggplotly output look like wide figures, though. Namely, you will need to add some padding on the left hand side of the plot in order to get the horizontal alignment with the paragraphs right. This can be achieved by the CSS rule below; you can put it right in your R Markdown file just before the ggplotly code chunk.

<style scoped>
.js-plotly-plot .plotly { padding-left: 65px; }

UPDATE: since BiocStyle version 2.5.7 you don't need to include the above CSS rule anymore.

ADD REPLYlink modified 22 months ago • written 23 months ago by Andrzej Oleś720
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 113 users visited in the last hour