I need to get my chart in descending order!

Asked

Viewed 49 times

0

what I’m wearing is :

tabyl(situacao$situacao)
  ggplot(situacao, aes(x=situacao))+
    geom_bar(stat="count", width=0.7, fill="steelblue")+
    theme_minimal() +
    theme(axis.text.x = element_text(angle = 90,size = 10))+
    scale_x_discrete(name ="Tipo de situação") +
    scale_y_continuous(name ="Adolescentes", breaks =seq(0,600,100))
    scale_y_continuous(name ="por adolescente")

As I leave it in descending order ?

  • 1

    Welcome to Stackoverflow! Unfortunately, this question cannot be reproduced by anyone trying to answer it. Please take a look at this link (mainly in the use of function dput) and see how to ask a reproducible question in R. So, people who wish to help you will be able to do this in the best possible way.

1 answer

0

It is always good to leave a reproducible example to receive appropriate responses. As stated in the comment, always leave a dput of data.

To leave a graph in descending order, you can use the function reorder. Since your code does not indicate the data you are using, I will create an example code.

df <- data.frame(x = 1:10, y = 1:10)

df %>%
    ggplot(aes(x = reorder(x, -x), y)) +
    geom_col()

[inserir a descrição da imagem aqui

Browser other questions tagged

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