Open bart-vanvlerken opened 1 month ago
thanks for the suggestion. @laresbernardo is it a font in lares package? maybe just change to something more standard?
Hi! This is a once-per-session warning to let the user know the font intended to be used in the plots can't be used because it can't be found or it's not installed in your OS. There are a couple of things the user can do:
suppressWarnings()
sysfonts::font_add_google("Pragati Narrow")
(which is a similar font) and setting that new font as defaultOne of the main benefits of this font usage is that we can add a lot of text in narrower spaces (which for Robyn is quite useful). You'll get nicer and better results if you have the font installed.
Hi, I'm also facing this issue, but I haven't been able to solve it. Ignoring the error is also not option, because of likely this font issue, the one-pager does not display all info: https://github.com/facebookexperimental/Robyn/issues/986
‘3.10.5.9000’
Sys.setenv(RETICULATE_PYTHON = "/opt/conda/envs/env_name/bin/python")
It seems 'Arial Narrow' is a Microsoft font and therefore not included by default on Linux systems.
The suggested workaround by @bart-vanvlerken is not working for me. I executed the commands:
install.packages("sysfonts")
library(sysfonts)
font_add(family = 'Arial Narrow', regular = 'arialnarrow.ttf')
But when executing the commands:
library(Robyn)
plot_adstock(plot = TRUE)
plot_saturation(plot = TRUE)
I'm getting the warning:
Warning message in .font_global(font, quiet = FALSE, ...):
“Font(s) 'Arial Narrow' not installed, with other name, or can't be found”
Warning message in geom_text(aes(x = max(.data$x), y = 0.5, vjust = -0.5, hjust = 1, :
“All aesthetics have length 1, but the data has 900 rows.
ℹ Please consider using `annotate()` or provide this layer with data containing
a single row.”
ChatGPT 4o recommended to use showtext
as an additional step, but that also didn't help.
install.packages("sysfonts")
# Enable showtext to use custom fonts
library(showtext) # You might also need this library to use custom fonts easily
showtext_auto() # Enables automatic use of showtext
After this, this command gives not error, but it still doesn't work with R:
plot(1:10, main = "Example Plot", family = "Arial Narrow")
Since ArialNarrow is a Microsoft font? this font is not included by default in a Debian (or other Linux release?). So I tried to install it with ttf-mscorefonts-installer, but that also didn't work:
contrib
repository to sudo nano /etc/apt/sources.list
:
deb http://deb.debian.org/debian bullseye main contrib non-free
deb-src http://deb.debian.org/debian bullseye main contrib non-free
deb http://deb.debian.org/debian bullseye-updates main contrib non-free deb-src http://deb.debian.org/debian bullseye-updates main contrib non-free
deb http://deb.debian.org/debian bullseye-backports main contrib non-free deb-src http://deb.debian.org/debian bullseye-backports main contrib non-free
deb http://security.debian.org/debian-security/ bullseye-security main contrib non-free deb-src http://security.debian.org/debian-security/ bullseye-security main contrib non-free
2. Install ttf-mscorefonts-installer
sudo apt update sudo apt install ttf-mscorefonts-installer sudo fc-cache -vr
3. Add package `extrafont`
conda activate my_env R install.packages("extrafont")
Then in R:
library(extrafont) font_import() loadfonts() fonts()
It seems `ttf-mscorefonts-installer` does not include 'Arial Narrow'.
### Move ArialNarrow.ttf to fonts folder
sudo cp ArialNarrow.ttf /usr/share/fonts/truetype/msttcorefonts/
R says the font is imported with:
library(extrafont) fonts()
but still `plot_adstock(plot = TRUE)` throws not found error.
Hi everyone, this error may be familiar to you - I've been getting it a lot. I resolved the warning message as follows:
This is something that could probably be included/circumvented in the Robyn code, but I hope this helps those looking for a solution.