1

I want to label only the outliers. This is the code that I did. I don't know a way to label only the outliers. It labels for all the points and makes the plot messy.

The STATE column has the US state names. I want to display only the states only that are outliers.

 p <-ggplot(data, aes(x=1, y=data$fact,label = STATE)) +geom_point(shape=1) +geom_boxplot() + geom_text(aes(label=STATE))

 plot <- ggplotly(p)

I want the labels to be displayed only for STATE - MA, RI and CT that are the outliers. Any suggestions? The plot result that I currently get,

enter image description here

  • create a subset of your data that you want labelled, i.e. those outside 1.5x the interquartile range (http://ggplot2.tidyverse.org/reference/geom_boxplot.html#computed-variables) then plot your main data set with no labels, and add your second dataset into the geom_text call – Scransom Jun 20 '18 at 01:58

0 Answers0