Using BiocStyle with plotly
1
0
Entering edit mode
@lluis-revilla-sancho
Last seen 4 days ago
European Union

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.

biocstyle plotly ggplot2 • 1.8k views
ADD COMMENT
3
Entering edit mode
Andrzej Oleś ▴ 750
@andrzej-oles-5540
Last seen 4.1 years ago
Heidelberg, Germany

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 COMMENT
0
Entering edit mode

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 REPLY
2
Entering edit mode

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 REPLY

Login before adding your answer.

Traffic: 893 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6