[R] ggplot2: labels and breaks order does not match and I can't use scale_fill_identity

From: Mikhail Spivakov <ensdev.box_at_googlemail.com>
Date: Tue, 29 Apr 2008 16:53:14 +0200


Hi,

I'm plotting a bar chart like this:

ggplot() +
geom_bar(data=res,aes(fill=f1,x=f2,y=y),stat="identity",position="dodge")

f1 contains quite a few levels and the plot is really quite difficult to read when the order of bars on the graph and on the legend does not match.

This problem has been discussed recently here: http://www.nabble.com/ggplot2---legend-for-fill-coulours-td16235166.html and the solution was to use scale_fill_identity to manually define the order of both the breaks and the labels.
This is however unsuitable for me (at least in the unmodified form), as this is part of a script that does not know in advance how many levels there arae in f1.

Is there a way round this problem?

Many thanks
Mikhail Spivakov

Mikhail Spivakov PhD
Postdoctoral Fellow
EMBL/EBI
Germany/UK

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 29 Apr 2008 - 16:49:40 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 30 Apr 2008 - 10:30:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive