Message-ID: <CAEQKoCGPvU3ZDdW2WqvsJM185vK5tj1u+MDmpec1AO8pbStMtw@mail.gmail.com>
Date: 2017-06-27T18:43:34Z
From: Brian Smith
Subject: ggplot2 geom_bar arrangement
Hi,
I was trying to draw a geom_bar plot. However, by default, the bars are
arranged according to the label, which I don't want. I want the bars to
appear exactly as they appear in the data frame. For example in the code:
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)
px <- ggplot(df,aes(Lab,valuex,label=Lab)) + geom_text(aes(y=0)) +
geom_bar(stat = "identity")
px
The default arranges the bars in order 'a' through 'f', but I want them
arranged as per df.
How can I do this?
thanks!
[[alternative HTML version deleted]]