ggplot(data = ames) +
geom_bar(mapping = aes(x = as.factor(Neighborhood),
y = Gr.Liv.Area,),
stat = "Summary",
fun = "mean" ,
fill = "sky blue") +
labs(title = "Overall Quality by Average Sales Price",
x ="Neighbourhood",
y = "Avergage living area (SqFt)") +
theme(axis.text.x = element_text(angle = 90, size = 8),
legend.position = "none")
Asked
Active
Viewed 16 times
0
-
1Difficult to help without data but have you tried this - https://stackoverflow.com/questions/5208679/order-bars-in-ggplot2-bar-graph ? – Ronak Shah Oct 28 '20 at 01:00
-
Simplest way is to `reorder` inside `geom_bar` like so: `geom_bar(aes(reorder(Neighborhood, -GrLivArea), GrLivArea), stat = "Summary", fun = "mean", fill = "sky blue")` – neilfws Oct 28 '20 at 01:13
-
1Check all the answers in the linked question as some are rather old now. – neilfws Oct 28 '20 at 01:14