Legend

26 views
Skip to first unread message

Sean Simpson

unread,
Mar 21, 2018, 12:15:49 PM3/21/18
to ggplot2
I am using scale_fill_manual and the legend is only producing 1 of my treatments. I think I am missing a line of code but not sure. Please help or point me in the direction of an answer.

ggplot(Cg1, aes(fill=ST, y=OC, x=CT)) + 
  geom_blank() + theme_bw() +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
  geom_bar(position="dodge", stat="identity", colour="black", size=.3) + 
  geom_errorbar(aes(ymin=OC-SE, ymax=OC+SE), width=.1, size=.1, # Width of the error bars
                position=position_dodge(.9)) + 
    scale_fill_manual(values = c("#999999","#FFFFFF","#666666","#CCCCCC","#999999","#FFFFFF","#666666","#999999","#FFFFFF"), name="", 
                   breaks=c("Sandy Loam", "Silt Laom", "Loam", "Loamy Sand", "Sandy Laom", "Silt Loam", "Loam", "Sandy Loam", "Silt Loam")) +
  xlab("Crop Type") + ylab("SOC (%)") + ggtitle("") + expand_limits(y=c(NA, 3.25))


Sean

Thierry Onkelinx

unread,
Mar 22, 2018, 4:49:19 AM3/22/18
to Sean Simpson, ggplot2
A minimal **working** example would make it much easier to see what is going on. You send the code, but failed to post some sample data.


ir. Thierry Onkelinx
Statisticus / Statistician

Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND FOREST
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
thierry....@inbo.be
Havenlaan 88 bus 73, 1000 Brussel
www.inbo.be

///////////////////////////////////////////////////////////////////////////////////////////
To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey
///////////////////////////////////////////////////////////////////////////////////////////



--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages