# Scatterplot with two different categories of data [duplicate]

I have a text document containing three columns. One column is "sex", and each value is either "M" or "F". The other two columns contain numerical data (my explanatory variable and response variable).

I want to create a Scatterplot in R where the point will look different for males than for females. I don't know how to do this.

## marked as duplicate by Nick Cox, gung♦, Glen_b♦ r StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Mar 1 '15 at 1:16

• You need a small reproducible example - a small set of data in R that you call dput on so that people attempting an answer can make the same data. In plot, the col argument gives different colors, the pch argument can get different symbols (including letters). – Glen_b Mar 1 '15 at 1:04
• Here's an example that uses both color and symbols plot(Sepal.Length~Sepal.Width,iris,col=Species,pch=as.numeric(Species)) and heres one with color and letters plot(Sepal.Length~Sepal.Width,iris,col=Species,pch=as.character(Species)) (but it's not so successful, since two species start with 'v') – Glen_b Mar 1 '15 at 1:13