[R] Order of bars w geom_errorbarh ??

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Mon May 2 14:42:42 CEST 2016

Ordering of any discrete values in ggplot goes according to the levels of the factor. As a convenience, ggplot will convert character values into factor for you according to the default order alphabetical). To take control of this you have to convert your discrete columns to factors yourself before giving the data to ggplot, e.g.

DF$somecol  <- factor( DF$somecol, levels=c("level1","level2",...) )

However, if you pull data from different factors in different input tables, ggplot has to combine them internally, and you will lose your specified ordering. With no minimum reproducible example I cannot tell whether that is a problem for you,  but the solution would be to combine them yourself before you give them to ggplot.
Sent from my phone. Please excuse my brevity.

On May 1, 2016 4:59:23 PM PDT, Judson Blake <parsifalblake at gmail.com> wrote:
>Using geom_errorbarh with ggplot, my plot has several error bars.   For
>presentation, the order of these bars from top to bottom is important.
>But errorbarh seems to put these in a random order I can't change.  (
>does not follow the order in the data.frame. )    How can I specify the
>order of the bars?   Could I also specify the thickness of the bar
>	[[alternative HTML version deleted]]
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]

More information about the R-help mailing list