I've searched through numerous tutorials, but cannot seem to crack what should be a basic couple of commands in R.
I'm trying to create a grouped barplot
in ggplot2
using mean percentage data from 11 categories (variable
: 0 to 10, which represent the number of times a salmon stream was enumerated) for two time periods
(1 & 2: Before & After).
My basic data are as follows:
period 1 = (0)7.5, (1)2.9, (2)6.8, (3)3.9, (4)4.1, (5)7.7, (6)4.4, (7)8.7, (8)10.8, (9)14.5, (10)28.8;
period 2 = (0)8.7, (1)2.5, (2)2.7, (3)6.5, (4)8.3, (5)7.9, (6)6.5, (7)8.8, (8)13.1, (9)13.7, (10)21.3;
The code I have used thus far to produce the paired barplot
is:
ggplot(data=data, aes(x=variable, y=value, fill=factor(period))) +
geom_bar(stat="identity", position="dodge") +
scale_fill_discrete(name="Period", breaks=c(1,2), labels=c("Before WSP", "After WSP")) +
xlab("Monitoring effort") +
ylab("Mean percentage")
which produces
/Users/price/Desktop/paired barplot.pdf
My question is, how do I change the x-axis ticks so that they all show (0 to 10....not simply "0", "2.5", etc.) and are not in decimals but whole numbers, and how do I change the colour of my bars to grey scale without disturbing the "fill" command of my legend?
Grateful for your help