Closed AlbertRapp closed 1 year ago
Hi @AlbertRapp and thanks for the issue!
Getting fonts to just work for plots inside R Markdown documents (or really anywhere that knitr is used) is tricky business. The reason that calling thematic::okabe_it(3)
changes how your plots render (i.e. the warnings about Merriweather not being found) is because thematic does a few things when the package is attached to set everything up so that it can work correctly.
It's an unfortunate consequence that this means that you can't use the package without it trying to work with knitr, but the advantage is that it's much easier to use thematic in all of the most common use cases.
If you're only interested in using the Okabe-Ito palette in your plot, I'd recommend using ggokabeito instead of thematic. Another option is to call thematic::okabe_ito(3)
in the R console and then copy the actual values into your script (in other words, don't attach thematic unless you need it 😄).
On the other hand, if you want to stick with thematic, I'd recommend adding a chunk like the following to your document, or incorporating this call into your setup chunk.
```{r}
#| message: false
thematic::thematic_rmd(font = "Merriweather")
If you're using a theme for your quarto document, you'll get best results if you add the `fg`, `bg`, and `accent` colors that match your document's theme.
HI @gadenbuie, thanks for the quick reply. I figured that this is probably intended behavior. I was just confused with the fact that I have used okabe_ito()
a lot and never ran into any trouble before yesterday. Turns out, whenever I used this function in a Quarto doc, I either didn't change the default fonts or used custom fonts that I imported anyway 😆
I think for now I'll just use okabe_ito()
to get the hex codes and put them into the code chunks manually. With the color highlighting in RStudio, that's also a nice touch 😆
Description
I like to use
thematic::okabe_ito()
to generate a color palette for my ggplots. I have used this many times inside and outside of Quarto docs without any issue. However, now I encounter a font rendering issue with this. For example, take a look at the following two code chunks:If I have both chunks in my Quarto doc, then the first renders just fine and the second one cannot render the "Merriweather" font anymore. Here's an image of that:
The key problem here is that I used
thematic::okabe_ito(3)
in my first code chunk. If I remove this, then both chunks render fine (I'm not using the colors in the plot). If I were to put the linemy_colors <- thematic::okabe_ito(3)
into a new code chunk before the first one, then none of the plots would render correctly.I get that
{thematic}
renders the fonts differently when I want to use the package to adjust the plots but here I am only grabing three hex codes that are saved inside of{thematic}
. This feels like an undesired consequence that I didn't run into before (and I have usedthematic::okabe_ito()
extensively).Apart from that, I have used Merriweather here. And since it is a Google font, I gather from #107 and the link from that issue there that rendering should work even if
{thematic}
takes over.Also, let me note that I am not quite sure whether this is a Quarto issue or
{thematic}
issue. Let me know if I should move this issue to Quarto.Session Info