Reputation: 1600
When I am plotting this ggplot in r, my y axis is labeled between 0 and 1. I don't understand where this comes from, as my values are not only comprised between 0 and 1? I would like my y axis to represent the values of my data frame.
Here is a sample of my data:
mydata<-data.frame(
value=runif(6,0,100),
type=rep(c("a","b"),6),
animal=c("h","h","c","c","c","h"),
eval=c(1,2,1,2,1,1),
frame2=letters[1:6])
ggplot(mydata,aes(x = frame2, y = value, fill=type)) +
theme_classic()+
scale_fill_manual(values=c('#bcbbb8','#FFFFFF','#ffce0c'))+
geom_bar(position = "fill",stat = "identity")+
facet_grid(animal ~ eval)
head(mydata)
value type animal eval frame2
1 76.190681 a h 1 a
2 82.086541 b h 2 b
3 14.002725 a c 1 c
4 67.064677 b c 2 d
5 3.035823 a c 1 e
6 55.560134 b h 1 f
Upvotes: 2
Views: 1050
Reputation: 887891
We can do this by removing the position = "fill
ggplot(mydata,aes(x = frame2, y = value, fill=type)) +
theme_classic()+
geom_bar(stat = "identity")+
facet_grid(animal ~ eval)
NOTE: Using the default colors instead of the custom ones where one of them is 'white'.
-output
Upvotes: 2