Skip to content
Prev 370100 / 398503 Next

ggplot2 geom_bar arrangement

You just have to change the levels of the factor ...

library(ggplot2)

Lab = c(letters[4:6], letters[1:3])
valuex = c(3.1,2.3,0.4,-0.4,-1.2,-4.4)
df <- data.frame(Lab,valuex)

# set the factor levels to the same order as observed in the data frame
df$Lab <- factor(df$Lab, levels=unique(df$Lab))

px <- ggplot(df,aes(Lab,valuex,label=Lab)) +
  geom_text(aes(y=0)) +
  geom_bar(stat = "identity")
px

Jean
On Tue, Jun 27, 2017 at 1:43 PM, Brian Smith <bsmith030465 at gmail.com> wrote: