0

I have been trying to produce a plot in just grayscale for the confidence interval fill and black lines for the predicted lines. I have tried every lead I find online and so far it has not produced a plot in grayscale. Much obliged for any help.

For reference, Predictor 1 is a categorical variable (3 levels) and Predictor 2 is a continuous predictor variable.

library(ggthemes)
ggplot() +
geom_ribbon(data=yhat, aes(x=Predictor2, ymax=fit+se*1.96, 
ymin=fit-se*1.96, fill=Predictor1), alpha=0.5)+ geom_line(data=yhat,
aes(Predictor2, fit, color=Predictor1), size=1.5)
+xlab('') + ylab('') + ggtitle('')+
theme_few(base_size=14)+ scale_y_continuous(limits=c(0,1))+
geom_abline(aes(intercept=0.5,slope=0),linetype="dashed")
MRB
  • 13
  • 3
  • Have you tried `scale_fill_gradient`? – cr1msonB1ade Jun 19 '15 at 18:36
  • You should include a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data so we can actually run your code to see what is being produced. – MrFlick Jun 19 '15 at 18:51
  • 1
    Perhaps `scale_colour_brewer(palette="Greys")` (resp. `scale_fill...`) or something similar? – Daniel Jun 19 '15 at 18:53

1 Answers1

0

you can create your own pallette for ggplot

pallette_yellow_green <- c("#ffff00", "#d4e100", "#bfd300", "#95b500", "#80a600", "#6a9700", "#558800", "#2b6b00", "#155c00", "#003400")

and then

 ggplot()+scale_fill_manual(values = pallette_yellow_green)

how to find color codes? use for example http://www.colorhexa.com/ (go for gradient generator)

that settles the issue for discrete variable

for continuous variables scale_fill_continuous or scale_fill_gradient should set you up: http://docs.ggplot2.org/0.9.3.1/scale_gradient.html

drsh1
  • 54
  • 7
  • Thanks all for the help! Sorry I didn't post the rest of code. I will do so for future questions. drsh1's comment did the trick! Thanks again. – MRB Jun 22 '15 at 13:16
  • please mark my answer as correct so I can get reputation boost :) – drsh1 Jun 22 '15 at 13:37