Error in Grid.Call(L_Textbounds, As.Graphicsannot(X$Label), X$X, X$Y,:Polygon Edge Not Found

Problem with error in ggplot: “Error in grid.Call(”L_textBounds“, as.graphicsAnnot(x$label), x$x, x$y, … ”

I updated my packages, restarted my machine and suddenly it worked. I do not know why, but I am happy that it know works. Thanks a lot to all the contributors - SO is just great!

Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font width unknown for character 0x20

I tried to make it work using extrafont but did not succeed. I am still not quite sure but I think it is a bug. Here is a solution using the package showtext:

---
title: "Embedding Fonts in PDF"
output: pdf_document
urlcolor: blue
---

```{r include=FALSE}
# notice the chunk option 'fig.showtext' that tells R to use the showtext
# functionalities for each ne graphics device opened
knitr::opts_chunk$set(dev = 'pdf', cache = FALSE, fig.showtext = TRUE)

library(ggplot2)
library(showtext)

font_add(family = "Lato", regular = "/Users/martin/Library/Fonts/Lato-Light.ttf")
```


### Plot with newly set standard font (= Lato) {#lato}
```{r echo=FALSE, out.width = '100%'}
ggplot(mtcars, aes(x=wt, y=mpg)) +
geom_point() +
ggtitle("Fuel Efficiency of 32 Cars") +
xlab("Weight (x1000 lb)") +
ylab("Miles per Gallon") +
theme(text = element_text(family="Lato"))
```

R Sample Image 25



Related Topics



Leave a reply



Submit