r-minimal
r-minimal copied to clipboard
Issues with ggplotly
Hello,
I am encountering the following error when trying to render plotly
object (ggplotly(p)
) from Rmarkdown:
Error in dev_fun(file = tempfile(), width = width %||% 640, height = height %||% :
No font found in CairoFonts() for "Helvetica:style=Regular"
Calls: <Anonymous> ... bscols -> ggplotly -> ggplotly.ggplot -> gg2list -> dev_fun
Here's my Dockerfile
:
FROM rhub/r-minimal:4.1
RUN apk update \
&& apk add --no-cache libcurl curl-dev cairo-dev libxt-dev
RUN installr -d \
-a "fontconfig" \
-t "zlib-dev gfortran fontconfig-dev" \
data.table dplyr ggplot2 \
knitr rmarkdown tidyr \
tibble purrr BiocManager \
circlize plotly RColorBrewer \
stringr bit64 Cairo \
scales jsonlite htmltools \
fontawesome reactable crosstalk \
ComplexHeatmap svglite
RUN wget https://github.com/jgm/pandoc/releases/download/2.13/pandoc-2.13-linux-amd64.tar.gz && \
tar xzf pandoc-2.13-linux-amd64.tar.gz && \
mv pandoc-2.13/bin/* /usr/local/bin/ && \
rm -rf pandoc-2.13*
Any help would be much appreciated!
Edit: I should add that Rmarkdown renders perfectly with ggplot objects, but fails when using ggplotly()
You need to install fonts
https://wiki.alpinelinux.org/wiki/Fonts says that this should be probably enough:
apk add terminus-font ttf-inconsolata ttf-dejavu font-bitstream-* font-noto font-noto-cjk ttf-font-awesome font-noto-extra
font-bitstream-*
does not work, IDK if it should. But I get:
bash-5.1# fc-match "Helvetica:style=Regular"
NotoSans-Regular.ttf: "Noto Sans" "Regular"
You probably don't need all those font packages, btw.
Alternatively, you could also try this, but check the license of the MS fonts first: https://unix.stackexchange.com/a/438269/22660 This gives me:
apk --no-cache add msttcorefonts-installer fontconfig && update-ms-fonts && fc-cache -f
bash-5.1# fc-match "Helvetica:style=Regular"
Arial.ttf: "Arial" "Regular"