while trying to generate any plot using ggplot2
, the following error is given:
Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size 11 could not be loaded
I already searched the web, any remotely related post didn't solve the issue. The simple example that I'm trying to plot is :
f = data.frame(one = c(1:5), two = c(6:10))
ggplot(f, aes(one,two)) + geom_point()
I updated my ggplot2 (ggplot2_3.0.0)
yet it is still not working.
Edit: I'm working on ubuntu, and in the terminal, i.e. no Rstudio
In Ubuntu 18.04 and later open the terminal and type:
sudo apt install r-cran-plotly
This command will install r-cran-ggplot2 version 2.2.1-3 as a dependency in Ubuntu 18.04, so if you already have ggplot2 installed then uninstall it first, and let sudo apt install r-cran-plotly
install the package maintainers version of ggplot2.
In earlier Ubuntu releases than Ubuntu 18.04 plotly can be installed with the following commands, but you'll have a lot more fun working with R if your Ubuntu is 18.04 or later:
sudo R -e "install.packages('ggplot2', repos = 'http://cran.us.r-project.org')" sudo R -e "install.packages('plotly', repos = 'http://cran.us.r-project.org')"
Start R with the command R
Run the code in the original question. Type each of these commands after the command prompt and press Enter.
library(ggplot2)
f = data.frame(one = c(1:5), two = c(6:10))
ggplot(f, aes(one,two)) + geom_point()
Quit the R session.
q()
Or use the unabbreviated command quit()
but after a couple of times you'll want to use q()
to quit the R session instead.
The results of ggplot(f, aes(one,two)) + geom_point()
are shown in this screenshot.