Skip to content

spaghetti plots in R

8 messages · uday, Liviu Andronic, Rui Barradas +1 more

#
I would like to plat some spaghetti plots from my data , ma data is as
follows 
ak[1:3,]
          [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]     
[,8]      [,9]
[1,] 0.3211745 0.4132568 0.5649930 0.6920562 0.7760113 0.8118568 0.8609301
0.9088819 0.9326736
[2,] 0.3159234 0.4071270 0.5579212 0.6844584 0.7684690 0.8243702 0.8677043
0.8931288 0.9261926
[3,] 0.3075260 0.3993699 0.5493242 0.6765600 0.7614591 0.8127050 0.8537816
0.8884786 0.9343690
         [,10] [,11]    [,12]
[1,] 0.9605178     1 1.003940
[2,] 0.9647617     1 1.012930
[3,] 0.9618874     1 1.007103
dim(ak[1:3,])
[1]  3 12

pre[1:3,]
         [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]     [,8]    
[,9]    [,10]
[1,] 10.34615 52.02116 146.1736 243.2864 347.4150 431.6711 521.4271 629.0045
729.9594 827.8628
[2,] 10.34615 52.02539 146.3670 244.3871 350.1785 454.6706 546.5499 638.3344
741.9849 842.5700
[3,] 10.34615 52.02754 146.4656 244.9480 351.5865 457.1768 550.1341 643.0880
748.1114 850.0670
        [,11]    [,12]
[1,] 921.5508 956.4445
[2,] 953.9648 995.8201
[3,] 951.6384 987.9105

dim(pre) 3 12 

I have tried 
plot(ak[1,],pre[1,],type="l")
lines(ak[2,],pre[2,],type="l",col="red")
but it only works for few data, but I have very big list and data is in
matrix format. I would be very glad if someone can help me to fix this
issue. 


--
View this message in context: http://r.789695.n4.nabble.com/spaghetti-plots-in-R-tp4532021p4532021.html
Sent from the R help mailing list archive at Nabble.com.
#
On Wed, Apr 4, 2012 at 4:22 PM, uday <uday_143_4u at hotmail.com> wrote:
See:
require(sos)
findFn('spaghetti')


Liviu

  
    
  
#
Hi Liviu ,
thanks for post , but I could not find findFn('spaghetti') , I can see the
following functions in sos package 
Extract.findFn
findFn  
 grepFn
hits 
 installPackages 
PackageSum2
 PackageSummary
 print.findFn 
 sortFindFn
summary.findFn
 unionFindFn
 writeFindFn2xls


--
View this message in context: http://r.789695.n4.nabble.com/spaghetti-plots-in-R-tp4532021p4532171.html
Sent from the R help mailing list archive at Nabble.com.
#
On Wed, Apr 4, 2012 at 5:04 PM, uday <uday_143_4u at hotmail.com> wrote:
After installing 'sos', use the 'findFn()' function. For example, run
findFn('spaghetti')

See the documentation of ?findFn. Alternatively, look into RcmdrPlugin.sos.

Regards
Liviu
#
Hi Liviu ,
now I can see that function but the problem is that its only applicable for
single data frame. as I wrote in my first post that I got 2 different matrix
with same dimensions ( 3x 12 here in example) , so if I plot normal plot
using plot function 
plot(ak[1,],pre[1,],type="l")
lines(ak[2,],pre[2,],type="l",col="red")

but every files contains more than 1000 observations. 
Is it possible to use this function for two different matrix data ?

if yes then please let me know how to do it .


Thanks 
Uday 

--
View this message in context: http://r.789695.n4.nabble.com/spaghetti-plots-in-R-tp4532021p4532452.html
Sent from the R help mailing list archive at Nabble.com.
#
Hello,


uday wrote
Why not ?matplot  - "Plot the columns of one matrix against the columns of
another. "



ak <- as.matrix(read.table(text="
0.3211745 0.4132568 0.5649930 0.6920562 0.7760113 0.8118568 0.8609301
0.9088819 0.9326736 0.9605178     1 1.003940
0.3159234 0.4071270 0.5579212 0.6844584 0.7684690 0.8243702 0.8677043
0.8931288 0.9261926 0.9647617     1 1.012930
0.3075260 0.3993699 0.5493242 0.6765600 0.7614591 0.8127050 0.8537816
0.8884786 0.9343690 0.9618874     1 1.007103
"))

ak

pre <- as.matrix(read.table(text="
10.34615 52.02116 146.1736 243.2864 347.4150 431.6711 521.4271 629.0045
729.9594 827.8628 921.5508 956.4445
10.34615 52.02539 146.3670 244.3871 350.1785 454.6706 546.5499 638.3344
741.9849 842.5700 953.9648 995.8201
10.34615 52.02754 146.4656 244.9480 351.5865 457.1768 550.1341 643.0880
748.1114 850.0670 951.6384 987.9105
"))


matplot(t(ak), t(pre), type="l")

Note that t() was needed.

Hope this helps,

Rui Barradas


--
View this message in context: http://r.789695.n4.nabble.com/spaghetti-plots-in-R-tp4532021p4532706.html
Sent from the R help mailing list archive at Nabble.com.
#
Can't you just combine your matrices into a single matrix: rbind() or
cbind() should do the job.

Michael
On Wed, Apr 4, 2012 at 12:24 PM, uday <uday_143_4u at hotmail.com> wrote: