rainette
rainette copied to clipboard
Dimension of plot produced by rainette_plot() in HTML rendering
Hello @juba,
I’m using Quarto to render reports from my analyzes in R.
I produce a plot of my clustering with rainette_plot()
and the problem with the results from clustering is that over a few number of clusters, the plot doesn't render very well in HTML I would like to make it full width to see if it’s better.
I found some instructions to render content full width on this page: https://quarto.org/docs/authoring/article-layout.html, using this option for the code chunk:
#| column: page
But when I use it with the code chunk that produces my rainette_plot()
, the plot doesn't increase to full width.
Is there a parameter that we can use in the function to make it render the result full width?
I tried something similar when rendering to PDF, I wanted to have a page in landscape format. I saw instructions here to have a landscape page in PDF: https://stackoverflow.com/questions/25849814/rstudio-rmarkdown-both-portrait-and-landscape-layout-in-a-single-pdf. It works, but same problem: the plot doesn't render in full width.
Thanks a lot for your help!
Gabriel
Hi,
Would you have a sample HTML document I could take a look at ?
Thanks !
Hi,
Thank you for your help.
Just to be sure that I was understood correctly: the HTML file is generated by the rendering in Quarto, I don't produce it myself manually.
Here is an extract from the code in the Quarto file, with the YAML header and the code chunk in R that draws the plot:
---
title: "PhD thesis GP --- class 03, lesson 03"
toc: true
toc-depth: 4
number-sections: true
format:
html:
code-fold: true
df-print: kable
pdf:
colorlinks: true
tbl-colwidths: auto
df-print: paged
---
### Clustering of the discourse of the two teachers
```{r}
#| label: compute_clustering
#| output: false
#| echo: false
# here I create the dfm and proceed to Reinert's clustering
```
```{r}
#| label: display_clustering
#| output: true
#| echo: false
#| column: page
## Clustering description plot
rainette_plot(
res, dtm, k = clusters_number,
n_terms = 30,
free_scales = FALSE,
measure = "chi2",
show_negative = TRUE,
text_size = 12
)
```
and the HTML that is generated for this part is this:
<section id="clustering-of-the-discourse-of-the-two-teachers" class="level3 page-columns page-full" data-number="1.4">
<h3 data-number="1.4" class="anchored" data-anchor-id="clustering-of-the-discourse-of-the-two-teachers"><span class="header-section-number">1.4</span> Clustering of the discourse of the two teachers</h3>
<div class="cell page-columns page-full">
<div class="cell-output-display column-page">
<p><img src="class03_lesson03_files/figure-html/display_clustering-1.png" class="img-fluid" width="672"></p>
</div>
</div>
</section>
Does it help or would you need the whole .qmd and .html files?
Did you try modifying the fig-width
and fig-height
options ?
https://quarto.org/docs/computations/execution-options.html#figure-options
Yes, and it works, but it's not perfect…
I would like to define those options on a chunk level and not document-wide in the YAML header. When defined in the code chunks options, it doesn't seem possible to define a different format for HTML or PDF.
So, do I understand correctly that there is no parameter in the rainette_plot()
function to define the format of the output, but that the format should be managed on the document level or chunk level?
Yes, you're right. rainette
creates the plot, but its dimensions, ppi, etc. are not handled by it.
Ok thanks a lot @juba, I will try to manage those Quarto options somehow!