0

I am trying to do a scatter plot of 2 time series data - the data is stored in a data frame. The background of the image is quite grainy and axis labels are not visible when I do:

ggplot(data=dat,aes(x,y))+geom_point() 

With below, I get only dark vertical lines:

plot(dat$x,dat$y) 

plot() and ggplot() did work after applying as.numeric() to the data(as below) but the axis labels are indices[1,2,...] and not the range of actual values.

plot(as.numeric(dat$x),as.numeric(dat$y))
ggplot(data=dat,aes(as.numeric(x),as.numeric(y)))+geom_point()

I cannot post the images here as I am new to this forum.

agamesh
  • 559
  • 1
  • 10
  • 26
Neerav
  • 1,399
  • 5
  • 15
  • 25
  • 4
    Not reproducible: we need the results of `summary(dat)` or `str(dat)` at the very least. (I'm guessing that `x` got turned into a factor; try `as.numeric(as.character(dat$x))` ...) http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Ben Bolker Feb 14 '12 at 16:36
  • I'm going to guess that you forgot to turn the variable into a date... – hadley Feb 15 '12 at 02:21

1 Answers1

1

By default, the data was getting converted into factor while converting from matrix to data.frame. Below code fixed it.

data.frame(mydata,stringsAsFactors = FALSE)
Neerav
  • 1,399
  • 5
  • 15
  • 25