0

I have a data frame called bigDF:

                         time price side PointColor shares PointSize ShapeType
231   2014-12-10 18:07:14.000    50    B      green    287        10        16
37016 2014-12-10 18:07:14.555    50           black      0         1        10
37019 2014-12-10 18:07:15.428    50           black      0         1        10
232   2014-12-10 18:07:16.000    50    B      green    713        10        16
37020 2014-12-10 18:07:17.052    50           black      0         1        10
37021 2014-12-10 18:07:17.161    50           black      0         1        10
37023 2014-12-10 18:07:17.316    50           black      0         1        10
233   2014-12-10 18:07:26.000    50    B      green    200        10        16
37024 2014-12-10 18:07:27.066    50           black      0         1        10
234   2014-12-10 18:07:28.000    50    B      green    700        10        16
37027 2014-12-10 18:07:28.346    50           black      0         1        10
235   2014-12-10 18:07:31.000    50    B      green    100        10        16

When I go to plot the price and highlight some points I get and error:

 ggplot(bigDF, aes(x=time, y=price)) + geom_line() + geom_point(   aes(shape = as.factor(ShapeType)), size=PointSize, color = PointColor)



Error in do.call("layer", list(mapping = mapping, data = data, stat = stat,  : 
  object 'PointSize' not found

Why is point size not found? it is in the dataframe?

Thank you.

user3022875
  • 8,598
  • 26
  • 103
  • 167

1 Answers1

2

ggplot2 can only find the columns of data (without explicitly specifying DF$column) if you refer to them inside aes. I believe you want geom_point(aes(shape = as.factor(ShapeType), size=PointSize, color = PointColor)). Note the different placing of parentheses. Also note that this maps these variables to size and color. It looks like you'd also want to use as.factor with them and use scale_color_manual and scale_size_manual. I'd suggest to study some ggplot2 tutorials.

Roland
  • 127,288
  • 10
  • 191
  • 288