0

I'm kind of new to R and been facing problems with adjusting data values into a graph which I made using ggplot2.

Here is the code which I am using for generating the plot.

sample.data <- read.csv(file = file.choose())
sample.data1 <- read.csv(file = file.choose())
sample.data <- sample.data[c(1:754),c(2,6,7,8,10,11)]
sample.data1<- sample.data1[c(1:754),c(2:7)]
sample.data.combined <- data.frame(sample.data,sample.data1)

 A <- sample.data.combined$TIMESTAMP_UTC
 B <- sample.data.combined$SENTIMENT_VOLUME_1D
 D <- sample.data.combined$Open
 E <- sample.data.combined$High
 G <- sample.data.combined$Low
 A1 <- as.Date(A,format  = "%m/%d/%y")

 library(ggplot2)


P <- ggplot(sample.data.combined,aes(A1,B,colour = "red"))+
geom_line(aes(A1, D, colour="blue"), sample.data.combined) + 
geom_line(aes(A1, E, colour="yellow"), sample.data.combined) + 
geom_line(aes(A1, G, colour="violet"), sample.data.combined) 

P + scale_y_continuous(breaks=seq(20,50,1))

I am having trouble in making it more clear with respect to the axis and also from which we can read the data?

tonytonov
  • 25,060
  • 16
  • 82
  • 98
  • 1
    Without a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610) it is difficult to tell what you want. I think you first must put your data in long format (with `melt` from package `reshape2`) and then simply use `ggplot(sample.data.longformat, aes(x=A1,y=value,colour = type))+ geom_line()` – RHA Aug 09 '15 at 08:27
  • 2
    It's good you added the code, but we're still missing the sample data (toy data will be good) to try our answers. From the code, I can see you don't need to define `A` to `A1`, as `ggplot` and friends take the names of variables in data frames as arguments. Also, I think @RHA is right in suggesting you melt the data and use a long table, instead of the wide one you have. I'm also flagging this as probably having an answer here: http://stackoverflow.com/questions/24501001/r-ploting-two-plots-3-variables-with-one-x-axes-in-ggplot – PavoDive Aug 10 '15 at 14:52
  • It is kind of difficult to explain without adding a figure, but , I have figured out a solution. – pramod pillutla Aug 13 '15 at 01:03

0 Answers0