Natalia Resende
Natalia Resende

Reputation: 195

How to insert labels in dot charts?

I have a data frame that looks like this.

enter image description here

enter image description here

I want to plot a dot chart for this data, but with my code, the labels are not printed. Also, I want to fill the dots with colours. Is this possible?

The code below shows what I have alredy tried:

  lexical_density=read.csv("~/lexical_density_lit_job10.csv", sep=";")
  dat=lexical_density

dotchart(dat$Lexical.Density,labels=row.names(dat$TEXTS),
         main="Literature Domain", 
         xlab="Lexical Density")

I want to plot a chart like this

Upvotes: 0

Views: 249

Answers (1)

Tony Ladson
Tony Ladson

Reputation: 3649

Is this what you are after?

df <- data.frame(T = c('S', 'HT',' MT',' PF', 'PL', 'SF', 'SL'), 
                 LD = c(0.559, 0.576, 0.567, 0.585, 0.567, 0.566, 0.568), stringsAsFactors = FALSE)

dotchart(df$LD, labels = df$T,  bg = 'red')

Upvotes: 1

Related Questions