1

I try to use the font Linux Libertine to label my barplot. However, I get the following error when trying to save the graph:

In axis(if (horiz) 2 else 1, at = at.l, labels = names.arg, lty = axis.lty,  :
font family 'Linux Libertine' not found in PostScript font database

My code looks as follows:

barplot(sort.new,las=2,beside=TRUE,cex.names=1.5,family = "Linux Libertine",legend.text=rownames(sort.new),args.legend = c(cex=1.5))

I tried to set the default font for labelling the axes but couldn't find out how to this.

Patrick Balada
  • 1,330
  • 1
  • 18
  • 37
  • 1
    why would you think that this would work? did you see the "family" section of `?par` – rawr Jan 17 '16 at 15:13
  • @ rawr Thank you for your comment. That was my first approach: I set par(mfrow=c(1,1),family="Linux Libertine"). However, I got exactly the same error. – Patrick Balada Jan 17 '16 at 15:20
  • 1
    Your code here doesn't look wrong; R just can't find the font you're asking for. Does it work with a different font, e.g. "Georgia"? If so, it's either a name issue (when I installed it, it called itself "Linux Libertine O") or a font installation configuration issue (differs by OS). – alistaire Jan 17 '16 at 15:58
  • @alistaire Thank you for the reply. I just tried "Georgia" and R shows the exact same error. I've never faced this issue when saving plots (using hhe plot() function), so I guess the problem must be the function barplot(). What do you think? – Patrick Balada Jan 17 '16 at 16:05
  • 1
    `barplot(rnorm(10), runif(10), family = 'Linux Libertine O')` works fine for me. Double-check the name in your font manager. What OS are you on? – alistaire Jan 17 '16 at 16:09
  • 1
    If you want to consider `ggplot2` there is an elaborate discussion on changing chart fonts [here](http://stackoverflow.com/questions/4094094/modifying-fonts-in-ggplot2). – Konrad Jan 17 '16 at 16:10
  • Thank you all for the effort! @alistaire I am on 10.11.2 (El Capitan) – Patrick Balada Jan 17 '16 at 17:14
  • Go to Font Book, find Linux Libertine, [make sure it's called exactly "Linux Libertine",] and make sure it's enabled (right click on it and see if "Disable" is an option; it will say "Off" to the right if it's disabled). If none of those are the issue, uninstall and reinstall it. – alistaire Jan 17 '16 at 17:22
  • I can create the barplot now. However, as soon as I am trying to save it using pdf() ... graphics.off(), I get the error again! – Patrick Balada Jan 17 '16 at 17:25

0 Answers0