Bar graph ggplot in R

Asked

Viewed 155 times

4

inserir a descrição da imagem aqui

I would like to know how to remove these letters a that appear in the bar chart caption in ggplot in R. I want you to have the bar values the same way it appears in the image, but when I run the code, these a appear automatically in the caption.

Code:

CS = data.frame(
  Setores = factor(c("Comércio","Comércio","Serviços","Serviços")),
  Situação = factor(c("Admitidos","Desligados","Admitidos","Desligados"), 
                    levels=c("Admitidos","Desligados")),
  Quantidade = c(2604, -1766, 6826, -5331)

)

ggplot(data=CS, aes(x=Situação, y=Quantidade, fill=Setores)) +
  geom_bar(aes(fill = Setores), stat="identity", position="dodge") +
  geom_label(aes(label =round(Quantidade,0), group = Setores),
             colour = "black", position = position_dodge(width=1))

1 answer

4

Just put the argument show.legend = FALSE within the function geom_label:

ggplot(data=CS, aes(x=Situação, y=Quantidade, fill=Setores)) +
  geom_bar(aes(fill = Setores), stat="identity", position="dodge") +
  geom_label(aes(label =round(Quantidade,0), group = Setores),
             colour = "black", position = position_dodge(width=1),
             show.legend = FALSE)

inserir a descrição da imagem aqui

  • Thank you very much!!

  • 1

    It’s great to know that my response has helped you in some way. So consider vote and accept the answer, so that in the future other people who experience the same problem have a reference to solve it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.