[R] Plot two separate curves in R Graphics and R Lattice package

David Winsemius dwinsemius at comcast.net
Thu Apr 11 04:55:20 CEST 2013


On Apr 10, 2013, at 6:11 PM, jpm miao wrote:

> Thanks for your comments, David
>
> avg_cost_2012 and asset_2012 are numeric vectors of length 39
>
> while x2 and y1 are longer vectors whose range is about the same as  
> (avg_cost_2012, asset_2012)
>
> I also present the data by dput below. Is it clear? Thanks,

I've named the first object xy and the second object y1x2

xyplot( avg_cost_2012 ~ asset_2012, data=as.data.frame(xy),
           panel=function(x,y) {
           panel.xyplot(x,y, type="p")
            panel.points( x=y1x2[,'x2'], y= y1x2[,'y1'], col="red")} )



Throwing in the scales argument does  make the points from  
panel.points disappear.


>
> Miao
>
>  	asset_2012	avg_cost_2012
> 1	3973730.0	0.0032199310
> 2	2391575.8	0.0034866607
> 3	2840943.5	0.0051450067
> 4	2040943.0	0.0063589398
> 5	1982715.2	0.0062530448
> 6	1618162.2	0.0054400342
> 7	820082.2	0.0042134623
> 8	1658596.8	0.0048834145
> 9	1762794.0	0.0062155737
> 10	93439.5	0.0042552036
> 11	218481.2	0.0069238420
> 12	2332477.0	0.0048621108
> 13	725835.5	0.0008902909
> 14	811575.2	0.0129624864
> 15	292223.0	0.0026141820
> 16	153862.2	0.0075244299
> 17	1272367.2	0.0068988788
> 18	734199.0	0.0098799510
> 19	421404.5	0.0050479335
> 20	189047.5	0.0048211174
> 21	529102.0	0.0096373243
> 22	56833.0	0.0061710425
> 23	125856.2	0.0083900410
> 24	598893.8	0.0066222964
> 25	258240.0	0.0061297368
> 26	159086.2	0.0088192099
> 27	122863.0	0.0100925693
> 28	404699.5	0.0081477489
> 29	453514.5	0.0084070531
> 30	545028.0	0.0060956804
> 31	1233365.5	0.0061105819
> 32	1192758.2	0.0081616218
> 33	147563.2	0.0083796600
> 34	247293.0	0.0102826553
> 35	1074838.2	0.0074134232
> 36	459227.5	0.0086199724
> 37	202332.0	0.0090614422
> 38	377401.2	0.0069230414
> 39	1876752.5	0.0102260772
>
>  	x2	y1
> 1	50118.72	0.012116846
> 2	51286.14	0.012053508
> 3	52480.75	0.011990503
> 4	53703.18	0.011927830
> 5	54954.09	0.011865489
> 6	56234.13	0.011803480
> 7	57543.99	0.011741804
> 8	58884.37	0.011680460
> 9	60255.96	0.011619448
> 10	61659.50	0.011558769
> 11	63095.73	0.011498421
> 12	64565.42	0.011438406
> 13	66069.34	0.011378724
> 14	67608.30	0.011319373
> 15	69183.10	0.011260355
> 16	70794.58	0.011201669
> 17	72443.60	0.011143315
> 18	74131.02	0.011085294
> 19	75857.76	0.011027605
> 20	77624.71	0.010970248
> 21	79432.82	0.010913224
> 22	81283.05	0.010856531
> 23	83176.38	0.010800171
> 24	85113.80	0.010744143
> 25	87096.36	0.010688448
> 26	89125.09	0.010633085
> 27	91201.08	0.010578054
> 28	93325.43	0.010523355
> 29	95499.26	0.010468989
> 30	97723.72	0.010414954
> 31	100000.00	0.010361253
> 32	102329.30	0.010307883
> 33	104712.85	0.010254846
> 34	107151.93	0.010202140
> 35	109647.82	0.010149768
> 36	112201.85	0.010097727
> 37	114815.36	0.010046019
> 38	117489.76	0.009994643
> 39	120226.44	0.009943599
> 40	123026.88	0.009892888
> 41	125892.54	0.009842508
> 42	128824.96	0.009792461
> 43	131825.67	0.009742747
> 44	134896.29	0.009693364
> 45	138038.43	0.009644314
> 46	141253.75	0.009595596
> 47	144543.98	0.009547211
> 48	147910.84	0.009499157
> 49	151356.12	0.009451436
> 50	154881.66	0.009404047
> 51	158489.32	0.009356991
> 52	162181.01	0.009310267
> 53	165958.69	0.009263875
> 54	169824.37	0.009217815
> 55	173780.08	0.009172087
> 56	177827.94	0.009126692
> 57	181970.09	0.009081629
> 58	186208.71	0.009036899
> 59	190546.07	0.008992500
> 60	194984.46	0.008948434
> 61	199526.23	0.008904700
> 62	204173.79	0.008861299
> 63	208929.61	0.008818229
> 64	213796.21	0.008775492
> 65	218776.16	0.008733088
> 66	223872.11	0.008691015
> 67	229086.77	0.008649275
> 68	234422.88	0.008607867
> 69	239883.29	0.008566791
> 70	245470.89	0.008526048
> 71	251188.64	0.008485636
> 72	257039.58	0.008445558
> 73	263026.80	0.008405811
> 74	269153.48	0.008366396
> 75	275422.87	0.008327314
> 76	281838.29	0.008288565
> 77	288403.15	0.008250147
> 78	295120.92	0.008212062
> 79	301995.17	0.008174309
> 80	309029.54	0.008136888
> 81	316227.77	0.008099799
> 82	323593.66	0.008063043
> 83	331131.12	0.008026619
> 84	338844.16	0.007990528
> 85	346736.85	0.007954768
> 86	354813.39	0.007919341
> 87	363078.05	0.007884246
> 88	371535.23	0.007849483
> 89	380189.40	0.007815053
> 90	389045.14	0.007780955
> 91	398107.17	0.007747189
> 92	407380.28	0.007713756
> 93	416869.38	0.007680654
> 94	426579.52	0.007647885
> 95	436515.83	0.007615449
> 96	446683.59	0.007583344
> 97	457088.19	0.007551572
> 98	467735.14	0.007520132
> 99	478630.09	0.007489024
> 100	489778.82	0.007458249
> 101	501187.23	0.007427806
> 102	512861.38	0.007397695
> 103	524807.46	0.007367916
> 104	537031.80	0.007338470
> 105	549540.87	0.007309356
> 106	562341.33	0.007280574
> 107	575439.94	0.007252125
> 108	588843.66	0.007224007
> 109	602559.59	0.007196222
> 110	616595.00	0.007168770
> 111	630957.34	0.007141649
> 112	645654.23	0.007114861
> 113	660693.45	0.007088405
> 114	676082.98	0.007062281
> 115	691830.97	0.007036490
> 116	707945.78	0.007011031
> 117	724435.96	0.006985904
> 118	741310.24	0.006961109
> 119	758577.58	0.006936647
> 120	776247.12	0.006912517
> 121	794328.23	0.006888719
> 122	812830.52	0.006865254
> 123	831763.77	0.006842120
> 124	851138.04	0.006819320
> 125	870963.59	0.006796851
> 126	891250.94	0.006774714
> 127	912010.84	0.006752910
> 128	933254.30	0.006731438
> 129	954992.59	0.006710299
> 130	977237.22	0.006689491
> 131	1000000.00	0.006669016
> 132	1023292.99	0.006648873
> 133	1047128.55	0.006629063
> 134	1071519.31	0.006609585
> 135	1096478.20	0.006590438
> 136	1122018.45	0.006571625
> 137	1148153.62	0.006553143
> 138	1174897.55	0.006534994
> 139	1202264.43	0.006517177
> 140	1230268.77	0.006499692
> 141	1258925.41	0.006482540
> 142	1288249.55	0.006465720
> 143	1318256.74	0.006449232
> 144	1348962.88	0.006433076
> 145	1380384.26	0.006417253
> 146	1412537.54	0.006401762
> 147	1445439.77	0.006386603
> 148	1479108.39	0.006371777
> 149	1513561.25	0.006357282
> 150	1548816.62	0.006343120
> 151	1584893.19	0.006329291
> 152	1621810.10	0.006315793
> 153	1659586.91	0.006302628
> 154	1698243.65	0.006289795
> 155	1737800.83	0.006277294
> 156	1778279.41	0.006265126
> 157	1819700.86	0.006253290
> 158	1862087.14	0.006241786
> 159	1905460.72	0.006230614
> 160	1949844.60	0.006219775
> 161	1995262.31	0.006209268
> 162	2041737.94	0.006199093
> 163	2089296.13	0.006189251
> 164	2137962.09	0.006179740
> 165	2187761.62	0.006170562
> 166	2238721.14	0.006161717
> 167	2290867.65	0.006153203
> 168	2344228.82	0.006145022
> 169	2398832.92	0.006137173
> 170	2454708.92	0.006129656
> 171	2511886.43	0.006122472
> 172	2570395.78	0.006115620
> 173	2630267.99	0.006109100
> 174	2691534.80	0.006102913
> 175	2754228.70	0.006097057
> 176	2818382.93	0.006091534
> 177	2884031.50	0.006086343
> 178	2951209.23	0.006081485
> 179	3019951.72	0.006076959
> 180	3090295.43	0.006072765
> 181	3162277.66	0.006068903
> 182	3235936.57	0.006065374
> 183	3311311.21	0.006062176
> 184	3388441.56	0.006059311
> 185	3467368.50	0.006056779
> 186	3548133.89	0.006054579
> 187	3630780.55	0.006052710
> 188	3715352.29	0.006051175
> 189	3801893.96	0.006049971
> 190	3890451.45	0.006049100
> 191	3981071.71	0.006048561
> 192	4073802.78	0.006048354
> 193	4168693.83	0.006048480
> 194	4265795.19	0.006048937
> 195	4365158.32	0.006049727
> 196	4466835.92	0.006050850
> 197	4570881.90	0.006052304
> 198	4677351.41	0.006054091
> 199	4786300.92	0.006056210
> 200	4897788.19	0.006058662
> 201	5011872.34	0.006061445
>
> To use dput function to present the data
> > dput(cbind(avg_cost_2012, asset_2012))
> structure(c(0.00321993102627396, 0.00348666071050862,  
> 0.00514500670171978,
> 0.00635893976088426, 0.00625304477271035, 0.00544003417356045,
> 0.00421346233925224, 0.00488341453548038, 0.00621557372817221,
> 0.00425520359585793, 0.00692384201718875, 0.00486211080732891,
> 0.00089029087751351, 0.0129624864137572, 0.00261418199497039,
> 0.00752442992607212, 0.00689887882046544, 0.00987995102314728,
> 0.00504793348921874, 0.00482111735730959, 0.00963732431899178,
> 0.00617104252791857, 0.0083900410469978, 0.00662229644462707,
> 0.00612973679503377, 0.00881920986708858, 0.0100925692602712,
> 0.0081477488720749, 0.00840705306981286, 0.00609568037628165,
> 0.0061105818615996, 0.00816162181738723, 0.00837965998751208,
> 0.0102826552802113, 0.0074134231730932, 0.00861997236733968,
> 0.00906144215028246, 0.00692304142052871, 0.0102260771876649,
> 3973730, 2391575.75, 2840943.5, 2040943, 1982715.25, 1618162.25,
> 820082.25, 1658596.75, 1762794, 93439.5, 218481.25, 2332477,
> 725835.5, 811575.25, 292223, 153862.25, 1272367.25, 734199, 421404.5,
> 189047.5, 529102, 56833, 125856.25, 598893.75, 258240, 159086.25,
> 122863, 404699.5, 453514.5, 545028, 1233365.5, 1192758.25, 147563.25,
> 247293, 1074838.25, 459227.5, 202332, 377401.25, 1876752.5), .Dim =  
> c(39L,
> 2L), .Dimnames = list(NULL, c("avg_cost_2012", "asset_2012")))
>
> > dput(cbind(avg_cost_2012, asset_2012))
> structure(c(0.00321993102627396, 0.00348666071050862,  
> 0.00514500670171978,
> 0.00635893976088426, 0.00625304477271035, 0.00544003417356045,
> 0.00421346233925224, 0.00488341453548038, 0.00621557372817221,
> 0.00425520359585793, 0.00692384201718875, 0.00486211080732891,
> 0.00089029087751351, 0.0129624864137572, 0.00261418199497039,
> 0.00752442992607212, 0.00689887882046544, 0.00987995102314728,
> 0.00504793348921874, 0.00482111735730959, 0.00963732431899178,
> 0.00617104252791857, 0.0083900410469978, 0.00662229644462707,
> 0.00612973679503377, 0.00881920986708858, 0.0100925692602712,
> 0.0081477488720749, 0.00840705306981286, 0.00609568037628165,
> 0.0061105818615996, 0.00816162181738723, 0.00837965998751208,
> 0.0102826552802113, 0.0074134231730932, 0.00861997236733968,
> 0.00906144215028246, 0.00692304142052871, 0.0102260771876649,
> 3973730, 2391575.75, 2840943.5, 2040943, 1982715.25, 1618162.25,
> 820082.25, 1658596.75, 1762794, 93439.5, 218481.25, 2332477,
> 725835.5, 811575.25, 292223, 153862.25, 1272367.25, 734199, 421404.5,
> 189047.5, 529102, 56833, 125856.25, 598893.75, 258240, 159086.25,
> 122863, 404699.5, 453514.5, 545028, 1233365.5, 1192758.25, 147563.25,
> 247293, 1074838.25, 459227.5, 202332, 377401.25, 1876752.5), .Dim =  
> c(39L,
> 2L), .Dimnames = list(NULL, c("avg_cost_2012", "asset_2012")))
> > dput(cbind(y1,x2))
> structure(c(0.0121168460097573, 0.0120535083414464,  
> 0.0119905029411228,
> 0.0119278298087863, 0.011865488944437, 0.0118034803480749,  
> 0.0117418040197,
> 0.0116804599593122, 0.0116194481669117, 0.0115587686424983,  
> 0.0114984213860722,
> 0.0114384063976332, 0.0113787236771814, 0.0113193732247168,  
> 0.0112603550402394,
> 0.0112016691237491, 0.0111433154752461, 0.0110852940947302,  
> 0.0110276049822015,
> 0.0109702481376601, 0.0109132235611057, 0.0108565312525386,  
> 0.0108001712119587,
> 0.010744143439366, 0.0106884479347604, 0.010633084698142,  
> 0.0105780537295108,
> 0.0105233550288669, 0.01046898859621, 0.0104149544315404,  
> 0.010361252534858,
> 0.0103078829061627, 0.0102548455454547, 0.0102021404527338,  
> 0.0101497676280001,
> 0.0100977270712536, 0.0100460187824943, 0.00999464276172216,
> 0.00994359900893722, 0.00989288752413946, 0.0098425083073289,
> 0.00979246135850551, 0.00974274667766932, 0.0096933642648203,
> 0.00964431411995847, 0.00959559624308384, 0.0095472106341964,
> 0.00949915729329613, 0.00945143622038305, 0.00940404741545717,
> 0.00935699087851848, 0.00931026660956695, 0.00926387460860262,
> 0.00921781487562548, 0.00917208741063551, 0.00912669221363276,
> 0.00908162928461716, 0.00903689862358877, 0.00899250023054757,
> 0.00894843410549355, 0.0089047002484267, 0.00886129865934705,
> 0.00881822933825459, 0.00877549228514933, 0.00873308750003123,
> 0.00869101498290033, 0.00864927473375661, 0.00860786675260009,
> 0.00856679103943074, 0.00852604759424859, 0.00848563641705362,
> 0.00844555750784583, 0.00840581086662524, 0.00836639649339183,
> 0.00832731438814562, 0.00828856455088657, 0.00825014698161472,
> 0.00821206168033005, 0.00817430864703257, 0.0081368878817223,
> 0.00809979938439918, 0.00806304315506327, 0.00802661919371454,
> 0.00799052750035301, 0.00795476807497865, 0.00791934091759149,
> 0.0078842460281915, 0.0078494834067787, 0.0078150530533531,  
> 0.00778095496791469,
> 0.00774718915046345, 0.00771375560099939, 0.00768065431952253,
> 0.00764788530603284, 0.00761544856053037, 0.00758334408301507,
> 0.00755157187348694, 0.00752013193194602, 0.00748902425839228,
> 0.00745824885282571, 0.00742780571524633, 0.00739769484565418,
> 0.00736791624404916, 0.00733846991043136, 0.00730935584480073,
> 0.0072805740471573, 0.00725212451750105, 0.00722400725583199,
> 0.00719622226215011, 0.00716876953645541, 0.00714164907874794,
> 0.00711486088902762, 0.0070884049672945, 0.00706228131354857,
> 0.00703648992778981, 0.00701103081001822, 0.00698590396023384,
> 0.00696110937843665, 0.00693664706462666, 0.00691251701880381,
> 0.00688871924096819, 0.00686525373111974, 0.00684212048925849,
> 0.00681931951538441, 0.0067968508094975, 0.00677471437159781,
> 0.00675291020168529, 0.00673143829975996, 0.00671029866582183,
> 0.00668949129987087, 0.0066690162019071, 0.00664887337193053,
> 0.00662906280994112, 0.00660958451593892, 0.0065904384899239,
> 0.00657162473189606, 0.00655314324185539, 0.00653499401980194,
> 0.00651717706573567, 0.00649969237965659, 0.00648253996156468,
> 0.00646571981145995, 0.00644923192934242, 0.00643307631521209,
> 0.00641725296906895, 0.00640176189091297, 0.00638660308074418,
> 0.00637177653856259, 0.00635728226436819, 0.00634312025816097,
> 0.00632929051994092, 0.00631579304970808, 0.00630262784746244,
> 0.00628979491320396, 0.00627729424693267, 0.00626512584864858,
> 0.00625328971835167, 0.00624178585604192, 0.00623061426171939,
> 0.00621977493538403, 0.00620926787703585, 0.00619909308667488,
> 0.00618925056430109, 0.00617974030991447, 0.00617056232351507,
> 0.00616171660510281, 0.00615320315467778, 0.00614502197223991,
> 0.00613717305778924, 0.00612965641132575, 0.00612247203284944,
> 0.00611561992236033, 0.0061091000798584, 0.00610291250534367,
> 0.00609705719881611, 0.00609153416027573, 0.00608634338972257,
> 0.00608148488715655, 0.00607695865257775, 0.00607276468598614,
> 0.00606890298738169, 0.00606537355676445, 0.00606217639413439,
> 0.00605931149949152, 0.00605677887283583, 0.00605457851416734,
> 0.00605271042348603, 0.00605117460079189, 0.00604997104608494,
> 0.00604909975936518, 0.00604856074063263, 0.00604835398988726,
> 0.00604847950712906, 0.00604893729235803, 0.00604972734557423,
> 0.0060508496667776, 0.00605230425596814, 0.00605409111314588,
> 0.00605621023831082, 0.00605866163146293, 0.00606144529260223,
> 50118.7233627273, 51286.1383991365, 52480.7460249772,  
> 53703.1796370253,
> 54954.0873857625, 56234.1325190349, 57543.9937337157, 58884.365535559,
> 60255.9586074358, 61659.5001861482, 63095.7344480193,  
> 64565.4229034656,
> 66069.3448007596, 67608.2975391982, 69183.0970918936,  
> 70794.5784384139,
> 72443.5960074991, 74131.0241300918, 75857.7575029184,  
> 77624.7116628693,
> 79432.8234724282, 81283.05161641, 83176.3771102671, 85113.8038202378,
> 87096.3589956081, 89125.0938133746, 91201.083935591, 93325.4300796992,
> 95499.2586021437, 97723.7220955811, 1e+05, 102329.299228075,
> 104712.85480509, 107151.930523761, 109647.819614319, 112201.845430196,
> 114815.362149688, 117489.755493953, 120226.443461741,  
> 123026.877081238,
> 125892.541179417, 128824.955169313, 131825.673855641,  
> 134896.288259165,
> 138038.426460289, 141253.754462276, 144543.977074593,  
> 147910.838816821,
> 151356.124843621, 154881.661891248, 158489.319246111,  
> 162181.009735893,
> 165958.690743756, 169824.365246175, 173780.082874938,  
> 177827.941003892,
> 181970.085860998, 186208.713666287, 190546.071796325,  
> 194984.459975805,
> 199526.231496888, 204173.794466953, 208929.613085404,  
> 213796.208950223,
> 218776.162394955, 223872.113856834, 229086.765276777,  
> 234422.881531992,
> 239883.291901949, 245470.891568503, 251188.643150958,  
> 257039.578276886,
> 263026.799189538, 269153.480392691, 275422.870333817,  
> 281838.293126445,
> 288403.150312661, 295120.922666639, 301995.172040202,  
> 309029.543251359,
> 316227.766016838, 323593.656929628, 331131.121482591,  
> 338844.156139203,
> 346736.850452532, 354813.389233575, 363078.054770102,  
> 371535.229097173,
> 380189.396320561, 389045.14499428, 398107.170553498, 407380.277804113,
> 416869.383470336, 426579.518801593, 436515.832240167,  
> 446683.592150963,
> 457088.189614875, 467735.141287198, 478630.092322638,  
> 489778.819368447,
> 501187.233627272, 512861.383991365, 524807.460249773,  
> 537031.796370253,
> 549540.873857625, 562341.325190349, 575439.937337157, 588843.65535559,
> 602559.586074358, 616595.001861482, 630957.344480194,  
> 645654.229034656,
> 660693.448007596, 676082.975391982, 691830.970918936,  
> 707945.784384139,
> 724435.960074991, 741310.241300918, 758577.575029184,  
> 776247.116628693,
> 794328.234724282, 812830.5161641, 831763.771102671, 851138.038202376,
> 870963.589956081, 891250.938133746, 912010.83935591, 933254.300796992,
> 954992.586021437, 977237.220955811, 1e+06, 1023292.99228075,
> 1047128.5480509, 1071519.30523761, 1096478.19614319, 1122018.45430197,
> 1148153.62149688, 1174897.55493953, 1202264.43461741,  
> 1230268.77081238,
> 1258925.41179417, 1288249.55169313, 1318256.73855641,  
> 1348962.88259165,
> 1380384.26460289, 1412537.54462276, 1445439.77074593,  
> 1479108.38816821,
> 1513561.24843621, 1548816.61891248, 1584893.19246111,  
> 1621810.09735893,
> 1659586.90743756, 1698243.65246175, 1737800.82874938,  
> 1778279.41003892,
> 1819700.85860998, 1862087.13666287, 1905460.71796325,  
> 1949844.59975805,
> 1995262.31496888, 2041737.94466953, 2089296.13085404,  
> 2137962.08950223,
> 2187761.62394955, 2238721.13856834, 2290867.65276777,  
> 2344228.81531992,
> 2398832.91901949, 2454708.91568503, 2511886.43150958,  
> 2570395.78276886,
> 2630267.99189538, 2691534.80392691, 2754228.70333817,  
> 2818382.93126445,
> 2884031.50312661, 2951209.22666639, 3019951.72040202,  
> 3090295.43251359,
> 3162277.66016838, 3235936.56929628, 3311311.21482591,  
> 3388441.56139203,
> 3467368.50452532, 3548133.89233576, 3630780.54770102,  
> 3715352.29097173,
> 3801893.96320561, 3890451.4499428, 3981071.70553498, 4073802.77804113,
> 4168693.83470336, 4265795.18801593, 4365158.32240167,  
> 4466835.92150963,
> 4570881.89614875, 4677351.41287198, 4786300.92322638,  
> 4897788.19368447,
> 5011872.33627272), .Dim = c(201L, 2L), .Dimnames = list(NULL,
>     c("y1", "x2")))
>
>
>
>
> 2013/4/11 David Winsemius <dwinsemius at comcast.net>
>
> On Apr 10, 2013, at 12:44 AM, jpm miao wrote:
>
> Hi David,
>
>    Many thanks. I try to follow your example and code as follows:
>
> xyplot( avg_cost_2012 ~ asset_2012,
>           panel=function(x,y) {
>           panel.xyplot(x,y, type="p")
>            panel.lines(x2, y1,  
> col="red")},scales=list(x=list(log=10)))
>
> However, I do see the points "p" of "avg_cost_2012 ~ asset_2012",  
> but do not see the line for y1 against x2. y1 and x1 are numeric  
> vectors of the same size. How can I fix it?
>
> Without seeing the data it is difficult to enumerate the possible  
> errors you could be making.
>
> I say again:
>
> Your example was not presented in a form that lent itself to easy  
> editing. Please learn to use dput to present data structures.
>
> -- David
>
>
>
>
> Thnaks
>
> Miao
>
>
> 2013/4/10 David Winsemius <dwinsemius at comcast.net>
>
> On Apr 9, 2013, at 8:21 PM, jpm miao wrote:
>
> Thank you very much.
>
> Could it be done in Lattice package?
>
>
>
> Your example was not presented in a form that lent itself to easy  
> editing. Please learn to use dput to present data structures:
>
> xyplot( 4:6 ~ 1:3,
>        panel=function(x,y) {
>                 panel.xyplot(x,y, type="l")
>                 panel.points(x=c(1.1, 2.1), y=c(4.1, 5.1),  
> col="red") } )
>
> -- 
> David.
>
>
> Thanks,
>
> Miao
>
>
> 2013/4/10 Janesh Devkota <janesh.devkota at gmail.com>
>
> Hi,
>
> This should be fairly easy by using base R graphics.
>
> Lets suppose your first data is represented by (x1,y1) and second  
> data is
> represented by (x2,y2)
>
> You can use the following command.
> plot(x1,y1,type="l")
> points(x2,y2)
>
> Hope it helps.
>
>
> On Tue, Apr 9, 2013 at 8:24 PM, jpm miao <miaojpm at gmail.com> wrote:
>
> Hi,
>
>   How can I plot two curves with distinct x and y vectors? I would  
> like
> to
> join one of them by regular lines and plot the other just by points  
> (no
> lines). Can it be done in  regular R graphic tools, say "plot"  
> function?
> Can it be done in Lattice package, say "xyplot" function?
>
>   Thanks,
>
> Miao
>
> My data look like this: two curves with different vector size
>
> x                 y
> 3973730 0.00322  2391576 0.003487  2840944 0.005145  2040943 0.006359
> 1982715 0.006253  1618162 0.00544  820082.3 0.004213  1658597 0.004883
> 1762794 0.006216  93439.5 0.004255  218481.3 0.006924  2332477  
> 0.004862
> 725835.5 0.00089  811575.3 0.012962  292223 0.002614  153862.3  
> 0.007524
> 1272367 0.006899  734199 0.00988  421404.5 0.005048  189047.5 0.004821
> 529102 0.009637  56833 0.006171  125856.3 0.00839  598893.8 0.006622
> 258240
> 0.00613  159086.3 0.008819  122863 0.010093  404699.5 0.008148   
> 453514.5
> 0.008407  545028 0.006096  1233366 0.006111  1192758 0.008162   
> 147563.3
> 0.00838  247293 0.010283  1074838 0.007413  459227.5 0.00862  202332
> 0.009061  377401.3 0.006923  1876753 0.010226
> and
> x   y
> 50118.72 0.012117  51286.14 0.012054  52480.75 0.011991  53703.18
> 0.011928
> 54954.09 0.011865  56234.13 0.011803  57543.99 0.011742  58884.37  
> 0.01168
> 60255.96 0.011619  61659.5 0.011559  63095.73 0.011498  64565.42  
> 0.011438
> 66069.34 0.011379  67608.3 0.011319  69183.1 0.01126
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius, MD
> Alameda, CA, USA
>
>
>
> David Winsemius, MD
> Alameda, CA, USA
>
>

David Winsemius, MD
Alameda, CA, USA



More information about the R-help mailing list