Without seeing sample data from you, let's use the diamonds
data set built-in to ggplot2
.
# really, let's use a subset
di = head(diamonds, 500)
I'd strongly recommend using ggplot
rather than qplot
:
ggplot(di, aes(x = carat, y = price, color = cut, fill = clarity)) +
geom_point(shape = 21)
Inside aes()
you use unquoted column names. For something that is a constant, it goes outside the aes()
aesthetic mappings, in this case shape = 21
. (You can also use pch = 21
if you prefer the base graphics style name).
qplot
is intended to be a shortcut, and it should work something like this:
qplot(data = di, x = carat, y = price, col = cut, fill = clarity, pch = 21)
but in this case it can't tell what's in your data (all the unquoted column names) and what's not (21
), and since 21
is a numeric it assumes there will be a continuous scale for shapes, which isn't allowed. So there's an error.
A simpler plot would do fine with qplot
qplot(data = di, x = carat, y = price, col = cut)
but for this more complicated case, you're better off with ggplot
as above.