[R] How to suppress factor labels

2011-06-08 Thread James Rome
I am using ggplot2 to make a boxplot that overlays a scatterplot:
pp = qplot(time, error, data=times, size=I(1), geom=jitter, main=title,
ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
color=times$runway,
ylim=c(-30,40))
pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
print(pp2 + geom_boxplot(alpha=.5, color=blue,
outlier.colour=green, outlier.size=1))
The x variable is a factor for every minute from 0:60. My problem is
that ggplot2 labels every factor value on the x axis, and they overlap.
How can I make ggplot2 label only, say every 5th factor value on the x axis?

Thanks,
Jim

__
R-help@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.


Re: [R] How to suppress factor labels

2011-06-08 Thread Ista Zahn
Hi Jim,

See ?scale_x_discrete

Best,
Ista

On Wed, Jun 8, 2011 at 3:26 PM, James Rome jamesr...@gmail.com wrote:
 I am using ggplot2 to make a boxplot that overlays a scatterplot:
 pp = qplot(time, error, data=times, size=I(1), geom=jitter, main=title,
        ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
 color=times$runway,
        ylim=c(-30,40))
    pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
    print(pp2 + geom_boxplot(alpha=.5, color=blue,
 outlier.colour=green, outlier.size=1))
 The x variable is a factor for every minute from 0:60. My problem is
 that ggplot2 labels every factor value on the x axis, and they overlap.
 How can I make ggplot2 label only, say every 5th factor value on the x axis?

 Thanks,
 Jim

 __
 R-help@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.




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

__
R-help@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.


Re: [R] How to suppress factor labels

2011-06-08 Thread James Rome
I think the issue is that the x axis is a factor. How would ggplot2 know

which ones to drop? So it labels them all.
If I do the following, the labels get better:
pp = qplot(time, error, data=times, size=I(1), geom=jitter,
main=title,
ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
ylim=c(-30,40))
pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
+ scale_x_discrete(
breaks = c(0, 5, 10,
15,20,25,30,35,40,45,50,55,60),
labels=c(0, 5, 10,
15,20,25,30,35,40,45,50,55,60))
print(pp2 + geom_boxplot(alpha=.5, color=blue,
outlier.colour=green, outlier.size=1))

But this ruins the boxplot--I get one box instead of a box at every minute.


On 6/8/2011 3:59 PM, Ista Zahn wrote:

Hi James,
It's hard for me to see where the problem might be. Please post the
data using dput() or even better, make a simplified example that
illustrates the problem without all the other stuff going on. Chances
are that in the process of making a simplified example you will find
the problem yourself.

Best,
Ista

On Wed, Jun 8, 2011 at 3:41 PM, James Rome jamesr...@passur.com wrote:


 I actually tried that, and get the same plot if I am using it properly:

title=paste(Fitted RETA predictions for , airport,  the week of
 , date, sep=)
pp = qplot(time, error, data=times, size=I(1), geom=jitter,
 main=title,
ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
 color=times$runway,
ylim=c(-30,40))
pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
+ scale_x_discrete(breaks = seq(from=0, to=60, by=5),
 labels=seq(from=0, to=60, by=5))
print(pp2 + geom_boxplot(alpha=.5, color=blue,
 outlier.colour=green, outlier.size=1))

 The x-axis is unchanged.

 Thanks,
 Jim
 On 6/8/2011 3:31 PM, Ista Zahn wrote:

 Hi Jim,

 See ?scale_x_discrete

 Best,
 Ista

 On Wed, Jun 8, 2011 at 3:26 PM, James Rome jamesr...@gmail.com wrote:

 I am using ggplot2 to make a boxplot that overlays a scatterplot:
 pp = qplot(time, error, data=times, size=I(1), geom=jitter, main=title,
ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
 color=times$runway,
ylim=c(-30,40))
pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
print(pp2 + geom_boxplot(alpha=.5, color=blue,
 outlier.colour=green, outlier.size=1))
 The x variable is a factor for every minute from 0:60. My problem is
 that ggplot2 labels every factor value on the x axis, and they overlap.
 How can I make ggplot2 label only, say every 5th factor value on the x axis?

 Thanks,
 Jim

 __
 R-help@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@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.


Re: [R] How to suppress factor labels

2011-06-08 Thread Ista Zahn
On Wed, Jun 8, 2011 at 5:02 PM, James Rome jamesr...@passur.com wrote:
 I think the issue is that the x axis is a factor.

Rather the opposite I think. In the data you sent, time is numeric,
not a factor. This works for me:

qplot(factor(time), error, data=times, size=I(1), geom=boxplot) +
facet_wrap(~ runway, ncol=2) +
scale_x_discrete(breaks = seq(from=0, to=60, by=10))

Best,
Ista


How would ggplot2 know
 which ones to drop? So it labels them all.
 If I do the following, the labels get better:
    pp = qplot(time, error, data=times, size=I(1), geom=jitter,
 main=title,
        ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
        ylim=c(-30,40))
    pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
        + scale_x_discrete(
            breaks = c(0, 5, 10,
 15,20,25,30,35,40,45,50,55,60),
            labels=c(0, 5, 10,
 15,20,25,30,35,40,45,50,55,60))
    print(pp2 + geom_boxplot(alpha=.5, color=blue,
 outlier.colour=green, outlier.size=1))

 But this ruins the boxplot--I get one box instead of a box at every minute.


 On 6/8/2011 3:59 PM, Ista Zahn wrote:

 Hi James,
 It's hard for me to see where the problem might be. Please post the
 data using dput() or even better, make a simplified example that
 illustrates the problem without all the other stuff going on. Chances
 are that in the process of making a simplified example you will find
 the problem yourself.

 Best,
 Ista

 On Wed, Jun 8, 2011 at 3:41 PM, James Rome jamesr...@passur.com wrote:

 I actually tried that, and get the same plot if I am using it properly:

    title=paste(Fitted RETA predictions for , airport,  the week of
 , date, sep=)
    pp = qplot(time, error, data=times, size=I(1), geom=jitter,
 main=title,
        ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
 color=times$runway,
        ylim=c(-30,40))
    pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
        + scale_x_discrete(breaks = seq(from=0, to=60, by=5),
 labels=seq(from=0, to=60, by=5))
    print(pp2 + geom_boxplot(alpha=.5, color=blue,
 outlier.colour=green, outlier.size=1))

 The x-axis is unchanged.

 Thanks,
 Jim
 On 6/8/2011 3:31 PM, Ista Zahn wrote:

 Hi Jim,

 See ?scale_x_discrete

 Best,
 Ista

 On Wed, Jun 8, 2011 at 3:26 PM, James Rome jamesr...@gmail.com wrote:

 I am using ggplot2 to make a boxplot that overlays a scatterplot:
 pp = qplot(time, error, data=times, size=I(1), geom=jitter, main=title,
        ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
 color=times$runway,
        ylim=c(-30,40))
    pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
    print(pp2 + geom_boxplot(alpha=.5, color=blue,
 outlier.colour=green, outlier.size=1))
 The x variable is a factor for every minute from 0:60. My problem is
 that ggplot2 labels every factor value on the x axis, and they overlap.
 How can I make ggplot2 label only, say every 5th factor value on the x axis?

 Thanks,
 Jim

 __
 R-help@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.











-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

__
R-help@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.