Skip to content
Prev 165529 / 398506 Next

ggplot2 Xlim

I'm just a ggplot2 beginner, but...

It seems to me that you're mixing continuous and factor variables/concepts.
It looks to me as if ForkLength and Number are continuous values. But you'll
need to convert ForkLength into a factor before using geom="bar". I do that
and the graph "works" but the bars are extremely busy, which I assume is
what you mean by "crowded".

As I try several different things, I'm seeing error messages. Are you not
seeing error messages?

Is the bottom line that you simply want to display some continuous data in a
histogram-ish style, and you don't like the default "binning" of Number for
each of many ForkLengths?

If you simply use geom="line", things look clear and simple, no need to bin
or simplify or...

If you do end up using geom="bar", I believe the mistake you're making --
and I see an error message when I try -- is that you are using
scale_x_continuous whereas the X axis is discrete, so you should be using
scale_x_discrete. But then it will take some R magic to combine your "bins"
into wider bins so you get a "less crowded" look.

Or perhaps I'm misunderstanding?

   Wayne
Felipe Carrillo wrote: