# Scatter plot with two factor variables for black and white print

How can I best represent a scatter plot with two different factor variables. Consider the example problem,

df <- data.frame(x=rnorm(300),
y=rnorm(300),
type=factor(sample(c("a", "b", "c", "d"), 300, replace=T)),
class=factor(sample(c("1", "2", "3"), 300, replace=T, prob = c(.7, .25, .05))))


The scatter plot

ggplot(df, aes(x=x, y=y))+geom_point(aes(color=type, shape=class))


looks great on screen, but has poor readability when printed in black and white. On the other hand using facet_grid

ggplot(df, aes(x=x, y=y))+geom_point()+facet_grid(class~.)


,

I loose the structure in the data.

So can anyone suggest an alternative plot that looks great in black & white while preserving the data structure. I am wondering if there are any shape or other aesthetics I can modify.

• The purpose of your plot is unclear. What feature of your data do you want to emphasize? For now I would suggest to switch color and shape and to user a grey scale (or a photocopy save brewer scale): ggplot(df, aes(x=x, y=y))+geom_point(aes(shape=type, color=class), size = 3) + scale_color_grey() – Roland Feb 4 '16 at 8:41
• @jMatchew not sure what you mean by loose the structure in the data. – mtoto Feb 4 '16 at 12:56
• @Nick It looks general to me. I understand that ggplot is used only to illustrate the problem. Have I overlooked something that would make this question overly software-specific? – whuber Feb 4 '16 at 16:39
• @NickCox "How can I best represent a scatter plot with two different factor variables." You can't get more general than that. The plots are just illustration. You can ignore the code behind them. The actual question is seeking advice for data presentation which is off-topic on SO and on-topic here. They seem to know how to write ggplot2 code. – Roland Feb 5 '16 at 8:04
• The terminology "factor variables" is not universal across all software applying statistics. If this question is so utterly straightforward, why are there no answers? I surmise it's because the real question is not clear enough. I've suggested in previous comments: try different marker or point symbols. If the OP is not getting enough attention, they should try rewriting. – Nick Cox Feb 5 '16 at 8:23