Sorry Dennis,
Didn't realized I went off the list!
I found a solution for one of my problem: removing x-axis label!
with this code: ggplot(Final2, aes(x=spp, y=WPUE, fill=season)) +
geom_bar(position=position_dodge()) + geom_errorbar(aes(ymin=WPUE-wpue.se,
ymax=WPUE+wpue.se), size=.3,width=.2,position=position_dodge(.9)) +
scale_x_discrete("",
breaks=c("102","90","91","94","96"),
labels= rep("", 5)) + ylab("Biomass (Weight (kg)/tow)") +
scale_fill_grey(name="Survey season", breaks=c("summer",
"winter"), labels=c("Spring", "Fall"))+
coord_flip() + theme_bw() + opts(axis.title.x = theme_text(size = 10),
panel.grid.minor = theme_blank())
However, I am still trying to figure out how to fix the width of my two plots on
my final pdf. I would appreciate any help on this! Thank you.
On 2011-12-04, at 12:59 PM, Aurelie Cosandey Godin wrote:
> Thank you Denis,
>
> I changed my code as you suggested, however the "xlab" didn't
work & I tried something else (see below my new code), but I still get my
labels for my x-axis (coord_flip) in my b figure ("spp" 96, 94, 91,
etc...). See figure below.
> To answer your question, I would like that both of my figure a & b have
the same width on the final pdf. Right now they aren't because of the
legend.
>>
>> and (3) fix the width, such that both figures
>>> have the same appearance regardless of the legend.
>>
>> I'm afraid I don't understand clearly what you mean my
'same
>> appearance'. Could you provide a reproducible example, which
includes
>> (possibly fake) data as well as code?
>
>
>
> Here's my new code:
>
> (a<- ggplot(Final2, aes(x=spp, y=CPUE, fill=season)) +
> geom_bar(position=position_dodge()) +
> geom_errorbar(aes(ymin=CPUE-cpue.se, ymax=CPUE+cpue.se),
> size=.3, width=.2,
> position=position_dodge(.9)) + scale_x_discrete("Species",
>
breaks=c("102","90","91","94","96"),
>
labels=c("SPINYTAIL","THORNY","SMOOTH","DEEPWATER","JENSEN'S"))
+ ylab("Abundance (fish/tow)") + coord_flip() +
> scale_fill_grey() + theme_bw() + opts(axis.title.x > theme_text(size =
10), panel.grid.minor = theme_blank(),
> legend.position='none') )
>
> ##I added scale_x_discrete(NULL,
breaks=c("102","90","91","94","96"),
labels= rep(NULL, 5)) thinking that this would be able to remove my x-axis label
(coord_flip) but it didn't... any other ideas of how I can achieve this?
>
> (b<- ggplot(Final2, aes(x=spp, y=WPUE, fill=season)) +
geom_bar(position=position_dodge()) + geom_errorbar(aes(ymin=WPUE-wpue.se,
ymax=WPUE+wpue.se), size=.3,width=.2,position=position_dodge(.9)) +
scale_x_discrete(NULL,
breaks=c("102","90","91","94","96"),
labels= rep(NULL, 5)) + ylab("Biomass (Weight (kg)/tow)") +
scale_fill_grey(name="Survey season", breaks=c("summer",
"winter"), labels=c("Spring", "Fall"))+
coord_flip() + theme_bw() + opts(axis.title.x = theme_text(size = 10),
panel.grid.minor = theme_blank()) )
>
> pdf("polishing-layout3.pdf", width = 10, height = 6)
> grid.newpage()
> pushViewport(viewport(layout = grid.layout(1, 2)))
> vplayout <- function(x, y)
> viewport(layout.pos.row = x, layout.pos.col = y)
> print(a, vp = vplayout(1, 1))
> print(b, vp = vplayout(1, 2))
> dev.off()
>
> <PastedGraphic-2.pdf>
>
> Thank you very much!
> Aurelie
>
> On 2011-12-04, at 11:33 AM, Dennis Murphy wrote:
>
>> Hi:
>>
>> On Sun, Dec 4, 2011 at 5:21 AM, Aurelie Cosandey Godin <GodinA at
dal.ca> wrote:
>>> Dear list,
>>>
>>> I am new with ggplot2 and I have spend quiet some time putting
together the
>>> following code to create the attached plot. However there's
still a few
>>> things that I'm having trouble with!
>>> I would be grateful if someone can tell me how to fix (1) the
colour of my
>>> bars into grey scales
>>
>> One way is to provide greyscale values to scale_fill_discrete; e.g.,
>> values = c("grey50","grey20")
>>
>>> (2) removing the y-axis (species name) on the right
>>> figure to avoid duplication,
>>
>> In the second figure, insert either
>> ylab("")
>> or if you have a labs() statement that defines several titles at once,
>> labs(..., y = "", ...)
>>
>> and (3) fix the width, such that both figures
>>> have the same appearance regardless of the legend.
>>
>> I'm afraid I don't understand clearly what you mean my
'same
>> appearance'. Could you provide a reproducible example, which
includes
>> (possibly fake) data as well as code?
>>
>> Dennis
>>>
>>> Thank you very much in advance!
>>>
>>> --
>>> You received this message because you are subscribed to the ggplot2
mailing
>>> list.
>>> Please provide a reproducible example:
http://gist.github.com/270442
>>>
>>> To post: email ggplot2 at googlegroups.com
>>> To unsubscribe: email ggplot2+unsubscribe at googlegroups.com
>>> More options: http://groups.google.com/group/ggplot2
>>>
>>>
>>> The code is as follow:
>>>
>>>
>>> (a<-ggplot(Final2, aes(x=spp, y=CPUE, fill=season)) +
>>> geom_bar(position=position_dodge()) +
>>> geom_errorbar(aes(ymin=CPUE-cpue.se, ymax=CPUE+cpue.se),
>>> size=.3,
>>> width=.2,
>>> position=position_dodge(.9)) +
>>> xlab("Species") +
>>>
scale_x_discrete(breaks=c("100","102","107","88","90","91","92","93","94","96","98","99"),
>>>
labels=c("WINTER","SPINYTAIL","BIGELOW'S","SKATES
>>>
(NS)","THORNY","SMOOTH","ABYSSAL","LITTLE","DEEPWATER","JENSEN'S","WHITE","SOFT"))
>>> +
>>> ylab("Abundance (fish/tow)") + coord_flip() +
>>> theme_bw() + opts(axis.title.x = theme_text(size = 10)) +
>>> opts(panel.grid.minor = theme_blank()) +
opts(legend.position='none') )
>>>
>>> (b<-ggplot(Final2, aes(x=spp, y=WPUE, fill=season)) +
>>> geom_bar(position=position_dodge()) +
>>> geom_errorbar(aes(ymin=WPUE-wpue.se, ymax=WPUE+wpue.se),
>>> size=.3,
>>> width=.2,
>>> position=position_dodge(.9)) + xlab(NULL)+
>>>
scale_x_discrete(breaks=c("100","102","107","88","90","91","92","93","94","96","98","99"),
>>>
labels=c("WINTER","SPINYTAIL","BIGELOW'S","SKATES
>>>
(NS)","THORNY","SMOOTH","ABYSSAL","LITTLE","DEEPWATER","JENSEN'S","WHITE","SOFT"))+
>>> ylab("Biomass (Weight (kg)/tow)") +
scale_fill_hue(name="Survey season",
>>> # Legend label, use darker colors
>>> breaks=c("summer", "winter"),
>>> labels=c("Spring", "Fall")) +
coord_flip() +
>>> theme_bw() + opts(axis.title.x = theme_text(size = 10)) +
>>> opts(panel.grid.minor = theme_blank()))
>>>
>>> pdf("polishing-layout2.pdf", width = 10, height = 6)
>>> grid.newpage()
>>> pushViewport(viewport(layout = grid.layout(1, 2)))
>>> vplayout <- function(x, y)
>>> viewport(layout.pos.row = x, layout.pos.col = y)
>>> print(a, vp = vplayout(1, 1))
>>> print(b, vp = vplayout(1, 2))
>>> dev.off()
>>>
>>>
>>> Aurelie Cosandey-Godin
>>> Ph.D. student, Department of Biology
>>> Industrial Graduate Fellow, WWF-Canada
>>>
>>> Dalhousie University | Biology Dept. | 1459 Oxford Street |
>>> Halifax, NS |
>>> Canada
>>> B3H 4R2
>>>
>>> Phone: 1-902-494-2478 |
>>> cell: 1-902-412-3404 |
>>> Fax: 1-902-494-3736
>>> Email: godina at dal.ca | Skype: aureliegodinco |
>>> Web: wormlab.biology.dal.ca
>>>
----------------------------------------------------------------------------------------------------------------------------------------------------
>>> Want to learn more about sharks in Atlantic Canada? Visit
>>> ShARCC! www.atlanticsharks.org
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>> --
>> You received this message because you are subscribed to the ggplot2
mailing list.
>> Please provide a reproducible example: http://gist.github.com/270442
>>
>> To post: email ggplot2 at googlegroups.com
>> To unsubscribe: email ggplot2+unsubscribe at googlegroups.com
>> More options: http://groups.google.com/group/ggplot2
>>
>