I'm attempting to plot a simple density plot in RStudio. The plot itself shows up, but with no text and this error message:
50: In doTryCatch(return(expr), name, parentenv, handler) :
no font could be found for family "Arial"
I've tried Googling the answer and several people seem to have had the same problem, without any solutions being found.
I'm running RStudio (version 1.0.153) on a MacBook Pro (High Sierra, 10.13.3)
Here's the full code I am running:
lim <- vector()
xn <- vector()
for (j in 1:1000) {
ek <- rexp(10000,1)
i <- 1:10000
xn <- 1/sqrt(i) * sum(ek) - sqrt(i)
lim[j] <- xn[10000]
}
plot(density(lim))
I've already tried changing fonts (Helvetica doesn't work either) and resetting the graphics with dev.off()
.
I had this problem recently using High Sierra 10.13.5 RStudio 1.1.453 and R 3.5.0
. My plots all showed up without text but worked fine with the same version of R and RStudio on a mac running the previous OS. The command warnings() showed error messages with this text:
no font could be found for family "Arial"
I found that High Sierra has sometimes disabled fonts, even though they are in /Library/Fonts. There is a new app with the OS called Font Book.app. Some details are here.
Looking in the Font Book app, I found that Arial was indeed greyed out and turned off. I chose enable
from the popup menu and had to restart the computer before it worked on plots in RStudio and R. Restarting the software wasn't enough.
Just want to add a comment in case other users find this help page. I had a very similar issue to OP - Mac OS Mojave 10.14.5
, Rstudio 1.1.456
and R 3.6.0
Some additional information on R can not find fonts to be used in plotting
All of base R, lattice and ggplot all could not source font family Arial, so I agree it was a system issue not R specific. I had tried:
extrafont
package and import_font()
or font_add()
did not work and don't address the root causeFor me: trick was there are separate Font book libraries both for the computer (/Library/Fonts) and each user (/Users/userid/Library/Fonts) - ensure Arial active in both of those, my user font library was empty for some reason (despite restoring standard fonts) - copied fonts from computer font library & problem solved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With