I'm trying to use dotplots to express both sample data and sample metadata. Both data are continuous, numerical data and grouped into several Accessions. Unfortunately I can't get the continuous 'age' data to work in geom_dotplot unless I change it to categorical data using factor() and I have no idea why
samples.GN.df<- data.frame(
Protein1 = sample(1:30),
Accession = sample(c("yes", "no"), 30, replace = TRUE),
Age = sample(10:39)
)
This doesn't work:
ggplot(samples.GN.df, aes(y=Protein1, x=Accession))+
geom_dotplot(binaxis = 'y', stackdir = 'center', mapping = aes(fill = Age))
This does (although the dots no longer stack neatly but I can solve that next):
ggplot(samples.GN.df, aes(y=Protein1, x=Accession))+
geom_dotplot(binaxis = 'y', stackdir = 'center', mapping = aes(fill = factor(Age)))
I've tried various things to get it to work as continuous rather than discrete data but to no avail, it just comes up as all black, not even an error message to point me in the right direction.
Any help on this would be gratefully received!
(edited to add sample data)