ggplot2 Xlim
Thanks Hadley: I had already gone to your website and stat="identity" is what I needed.
--- On Fri, 12/26/08, hadley wickham <h.wickham at gmail.com> wrote:
From: hadley wickham <h.wickham at gmail.com> Subject: Re: [R] ggplot2 Xlim To: mazatlanmexico at yahoo.com Cc: r-help at r-project.org, "Wayne F" <wdf61 at mac.com> Date: Friday, December 26, 2008, 3:31 PM Hi Felipe, It sounds like ForkLength is a factor - what deos str(FL) tell you? You might also need geom_bar(..., stat = "identity") since your data are pretabulated. Hadley On Fri, Dec 26, 2008 at 2:44 PM, Felipe Carrillo <mazatlanmexico at yahoo.com> wrote:
Wayne: What's crowded are my x axis labels. The bars look
fine on my graph but the labels are being displayed from 29 to 170 one by one. I need something like a seq(29,170 by:10) or something like that. I don't want to treat my FL as factor because I don't want a bar per each FL value, I only want to count the number of FL at any given FL size. Thanks
--- On Thu, 12/25/08, Wayne F <wdf61 at mac.com>
wrote:
From: Wayne F <wdf61 at mac.com> Subject: Re: [R] ggplot2 Xlim To: r-help at r-project.org Date: Thursday, December 25, 2008, 2:43 PM 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:
Hi: I need some help. I am ploting a bar graph but I can't
adjust my x
axis scale
I use this code:
i <-
qplot(ForkLength,Number,data=FL,geom="bar")
i +
geom_bar(colour="blue",fill="grey65") #
too crowded
FL_dat <-
ggplot(FL,aes(x=ForkLength,y=Number)) +
geom_bar(colour="green",fill="grey65")
FL_dat +
scale_x_continuous(limits=c(20,170)) #
Can't see anything
FL Number 29 22.9 30 63.4 31 199.3 32 629.6 33 2250.1 ...
-- View this message in context:
Sent from the R help mailing list archive at
Nabble.com.
______________________________________________ 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.
______________________________________________ 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. -- http://had.co.nz/