Error: ! Problem while converting geom to grob. ℹ Error occurred in the 1st layer

15.3k Views Asked by At

I am running the examples at this link. After re-installing ggiraph, the same code that was working before, returns this error

Error:
! Problem while converting geom to grob.
ℹ Error occurred in the 1st layer.
Caused by error in `check.length()`:
! 'gpar' element 'lwd' must not be length 0
Run `rlang::last_error()` to see where the error occurred.

Any suggestion?

3

There are 3 best solutions below

0
NickE On BEST ANSWER

Which version of ggplot2 are you using? I was having trouble with an identical error from ggforce. In the end I got everything working with R 4.2.2, ggplot2 3.4.0, ggiraph 0.8.4 and ggforce 0.4.1.

0
Patrick Marti On

I had a similar problem when using geom_freqpoly in ggplot. There seemed to be a problem with xlim(). When I removed xlim() everything worked fine. Restaring RStudio solved the problem for me. R version 4.2.2 ggplot2_3.4.0

1
TWest On

Using st_zm(shapefile) should sove the problem.