ggplot: text printed by geom_text is not clear

ggplot2, r

Solution

Use `annotate` for the text as well as the arrow:

m + geom_histogram(colour = "blue", fill = "white", binwidth = 0.5) +
  annotate("segment", x=10,xend=10,y=20,yend=0,arrow=arrow(), color="blue") +
  annotate("text", x=10, y=30, label="Observed \n value", color = "blue")

The reason is that `geom_text` overplots the text for each row of data in the data frame, whereas `annotate` plots the text only once. It is this overplotting that causes the bold, pixellated text.

I am sure this question was answered recently. I'll try to find a reference: A similar question was asked recently:

- ggplot2: Is there a fix for jagged, poor-quality text produced by geom_text()?

- How to nicely annotate a ggplot2 (manual)

Problem

The text printed using geom_text is not very clear. How can I make it more clear? ``` data = data.frame(rnorm(1000)) colnames(data) = "numOfX" m <- ggplot(data, aes(x=numOfX)) m + geom_histogram(colour = "blue", fill = "white", binwidth = 0.5) + annotate("segment", x=10,xend=10,y=20,yend=0,arrow=arrow(), color="blue") + geom_text(aes(10, 30, label="Observed \n value"), color = "blue") ```

Original source

Related problems