Search
Question: Using BiocStyle with plotly
0
gravatar for Lluís R
4 months ago by
Lluís R300
European Union
Lluís R300 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.

ADD COMMENTlink modified 4 months ago by Andrzej Oleś670 • written 4 months ago by Lluís R300
3
gravatar for Andrzej Oleś
4 months ago by
Andrzej Oleś670
EMBL Heidelberg, Germany
Andrzej Oleś670 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.

Cheers,
Andrzej

ADD COMMENTlink modified 4 months ago • written 4 months ago by Andrzej Oleś670

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 4 months ago by Lluís R300
2

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; }
</style>

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

ADD REPLYlink modified 4 months ago • written 4 months ago by Andrzej Oleś670
Please log in to add an answer.

Help
Access

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