I am trying to export a simple barplot using ggplot2. Everything works fine, but when the plot is printed it states the following error:
In grid.Call.graphics(L_text, as.graphicsAnnot(x$label), ... :
Zeichensatzfamilie in der Windows Zeichensatzdatenbank nicht gefunden
In english it would say:
In grid.Call(L_text, as.graphicsAnnot(x$label), ... :
font family not found in Windows font database
When I then try to export the file as pdf using the export button on top of the plot it never finishes saving the plot and I have to close Rstudio with the taskmanager.
I already read I should install the extrafont package, import and load the fonts, which I also did. This is the code I used:
library(ggplot2)
library(extrafont)
font_import()
y
loadfonts()
Data <- Liposarcoma.ARSA_2 #txt. file with my data
newData <- Data[-c(1,2),] #delete Header
errors <- as.numeric(newData$V10)
samplev <- data.frame(samples=(newData$V3), Target=(as.numeric(newData$V8)))
samplev #create dataframe for Target/ref
dodge <- position_dodge(width = 0.9)
limits <- aes(ymax = samplev$Target + errors,
ymin = samplev$Target - errors)
p <- ggplot(data = samplev, aes(x = samples, y = Target))
p + geom_bar(stat = "identity", position = dodge, fill="darkgrey") +
geom_errorbar(limits, position = dodge, width = 0.25) +
theme(axis.text.x=element_text(samplev$samples), axis.ticks.x=element_blank(),
axis.title.x=element_blank(), axis.text=element_text(size=12, colour="black"),
plot.title=element_text(size=18, face="bold")
) +
ylab("Target/Reference") +
ggtitle("ARSA: Liposarcoma cell lines") +
geom_text(data=samplev, aes(x=samples, y=Target+0.15, label=Target, vjust=0))
Thank you in advance :)
pdfFonts. It might be used to change the default fonts for that graphics device, although (not being an RStudio user yet) I suppose that RStudio might have its own mechanism for controlling graphics devices?pdf()device orggsave()instead of the RStudio button? Or setting a font that you know you have?