Linked Questions

2 votes
1 answer
15k views

ggplot2: reorder bars in barplot from highest to lowest [duplicate]

I got this figure Following the answer of similar question library(ggplot2) library(egg) mydf <- transform(mydf, variables = reorder(variables, VIP, decreasing = T)) p1 <- ggplot(mydf, ...
shiny's user avatar
  • 3,440
3 votes
1 answer
4k views

How do I reorder based on descending order for a specific variable in a grouped bar plot [duplicate]

I am trying to reorder the graph bars based on one of the variables, in this case the y variable in descending order instead of the alphabetical order of x. x<-c("Jan","Feb",&...
Sue's user avatar
  • 77
2 votes
1 answer
2k views

Ordering bar chart by value in R using ggplot2 [duplicate]

I am having trouble creating a bar chart utilizing ggplot2 that is sorted by value. I understand that I can order the data frame by the value and then plot it. However, ggplot2 seems to ignore the ...
Tobias's user avatar
  • 35
1 vote
0 answers
3k views

Sorting in ggplot with facet wrap [duplicate]

I used tidytext and ggplot to compute and plot bigram frequencies (and tf-idfs). I've plotted the most frequent bigrams across four time periods. However, I can't figure out how to correctly sort my ...
Andrea's user avatar
  • 25
0 votes
0 answers
382 views

ggplot geom_bar does not follow dataframe order [duplicate]

I'm trying to do a barplot where entries of the same factor are next to eachother so I can compare (in this example I want to compare the tissue type). I sort the dataframe but for some reason ggplot ...
Murd's user avatar
  • 9
-2 votes
2 answers
332 views

Include leading zero when using Rank function in R [duplicate]

testdf = data.frame(name=c("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o"), score = c(11,15,46,32,22,68,89,35,54,12,44,3,1,88,6)) testdf$rank<-rank(testdf$score) when using the rank ...
Tyler's user avatar
  • 93
-1 votes
1 answer
252 views

Change the order of xlabel in R using ggplot [duplicate]

i have a Graph in R, im using ggplot, this is my code: BreachTbl %>% dplyr::filter(!(is.na(country))) %>% ggplot2::ggplot() + geom_bar(aes(x = country)) + ...
Carlos Tellez's user avatar
-1 votes
1 answer
163 views

r - reordering of barplot with ggplot2 [duplicate]

Looking for how to reorder bars in ggplot2::geom_bar and none of the already posted answers helped solve the issue. A reproducible example: # sample dataframe cf <- data.frame(a = rnorm(1000, ...
adl's user avatar
  • 1,441
-2 votes
1 answer
157 views

Order data on ggplot [duplicate]

I currently have a ggplot however it is shown in alphabetical order, I want the graph to show the most 'important score' first and order in descending order. See image of plot attached and code. ...
Kate English's user avatar
1 vote
1 answer
55 views

Need to reorder the plot according to the total [duplicate]

I have a plot drawn to visualize the total energy each year like below. I want it to reorder as same as in the dataset (highest producer at the top) top10Producers %>% ggplot(aes(...
dly's user avatar
  • 233
1 vote
2 answers
66 views

R: How to reposition stacked bars based on total value in a stacked barplot? [duplicate]

I would like to have my stacked bar chart positioned along the x-axis based on total value. The default positioning is based on alphabetic order. I used the following code to plot the stacked bar ...
Max's user avatar
  • 11
0 votes
0 answers
56 views

How can I easily ad one colour in each bar and make it descending? [duplicate]

How can I easily ad one color in each bar and make it descending? QG4 %>% filter(value=="Yes") %>% ggplot(aes(y=Freq, x=variable))+ geom_bar(position = "dodge", stat =...
Simen Fjælberg's user avatar
0 votes
1 answer
35 views

Order a bar chart in a decreasing manner [duplicate]

I have a table showing genes, with numbers. I made a bar chart showing each gene with it's number but I'm failing to do so in an ordered way. This is the code : TOPGENES = data.frame(Gene.Name = c('...
Programming Noob's user avatar
0 votes
0 answers
25 views

R I have a dataframe that has been ordered desc by freq how do I get ggplot to show the freq in descending order, it shows by col name instead [duplicate]

I have a data frame with station_name. I have ordered the data frame by station_name frequency. There is some extra debug code in here. ```{r} df <- filter(df_clean_distances, start_station_name ...
Vanderdecken's user avatar
0 votes
0 answers
24 views

Reordering Bar Graph with ggplot2 in R [duplicate]

I need to reorder the bars in my bar chart from highest to lowest. How do I do this? Thank you in advance! Here is my coding: advertisement <- ("A", "B", "C") ...
Benjamin Newton's user avatar

15 30 50 per page