Good morning. I wish to plot two data on the same axis. I tried plot(x,y, type = "l") for the first and tried to use lines or points(x,y, lty = 2, col = 4) to add or plot the second data on alongside the first. However, what I got was not encouraging. I have attached the two data and would be pleased if anybody could be of help. Thank you Best regards Ogbos -------------- next part -------------- 05 1 1 3974.8 05 1 2 3967.2 05 1 3 3817.7 05 1 4 3789.4 05 1 5 3803.6 05 1 6 3831.4 05 1 7 3878.6 05 1 8 3861.5 05 1 9 3850.4 05 1 10 3855.0 05 1 11 3900.9 05 1 12 3952.2 05 1 13 3954.7 05 1 14 3942.9 05 1 15 3955.0 05 1 16 3934.1 05 1 17 3859.2 05 1 18 3530.9 05 1 19 3299.9 05 1 20 3398.1 05 1 21 3305.5 05 1 22 3457.7 05 1 23 3753.8 05 1 24 3846.8 05 1 25 3896.9 05 1 26 3914.3 05 1 27 3917.9 05 1 28 3910.1 05 1 29 3938.0 05 1 30 3975.7 05 1 31 3945.0 05 2 1 3952.3 05 2 2 3948.1 05 2 3 3946.7 05 2 4 3957.1 05 2 5 3968.9 05 2 6 3990.2 05 2 7 3980.0 05 2 8 3965.8 05 2 9 3952.8 05 2 10 3942.0 05 2 11 3938.9 05 2 12 3967.6 05 2 13 3986.9 05 2 14 3992.8 05 2 15 3982.8 05 2 16 3986.3 05 2 17 3972.5 05 2 18 3951.4 05 2 19 3929.4 05 2 20 3928.5 05 2 21 3939.6 05 2 22 3951.5 05 2 23 3950.2 05 2 24 3956.3 05 2 25 3970.4 05 2 26 3981.4 05 2 27 3994.2 05 2 28 3988.9 05 3 1 3997.1 05 3 2 4003.9 05 3 3 4011.0 05 3 4 4017.0 05 3 5 4003.2 05 3 6 3993.1 05 3 7 3996.8 05 3 8 3999.1 05 3 9 3988.6 05 3 10 4002.2 05 3 11 3997.9 05 3 12 3981.5 05 3 13 3996.8 05 3 14 4026.5 05 3 15 4025.5 05 3 16 4021.8 05 3 17 4016.5 05 3 18 4011.7 05 3 19 3975.9 05 3 20 3981.0 05 3 21 3961.2 05 3 22 3965.2 05 3 23 3981.5 05 3 24 3996.4 05 3 25 3981.9 05 3 26 3979.0 05 3 27 3976.5 05 3 28 3973.7 05 3 29 3959.5 05 3 30 3974.0 05 3 31 3980.2 05 4 1 3972.3 05 4 2 3982.2 05 4 3 4008.9 05 4 4 4007.0 05 4 5 4009.1 05 4 6 3990.5 05 4 7 4002.5 05 4 8 4027.3 05 4 9 4047.8 05 4 10 4039.4 05 4 11 4025.0 05 4 12 4025.3 05 4 13 4006.2 05 4 14 4013.0 05 4 15 4018.7 05 4 16 4031.2 05 4 17 4037.3 05 4 18 4053.2 05 4 19 4065.3 05 4 20 4065.5 05 4 21 4042.3 05 4 22 4004.8 05 4 23 3974.9 05 4 24 3995.5 05 4 25 4007.9 05 4 26 4005.5 05 4 27 4019.7 05 4 28 4030.3 05 4 29 4045.4 05 4 30 4031.4 05 5 1 3995.6 05 5 2 3978.2 05 5 3 3993.3 05 5 4 4018.4 05 5 5 4027.6 05 5 6 4006.0 05 5 7 3985.5 05 5 8 3993.1 05 5 9 3817.5 05 5 10 3849.4 05 5 11 3880.4 05 5 12 3896.8 05 5 13 3911.0 05 5 14 3922.4 05 5 15 3703.7 05 5 16 3703.8 05 5 17 3783.5 05 5 18 3809.5 05 5 19 3805.4 05 5 20 3837.9 05 5 21 3876.8 05 5 22 3898.2 05 5 23 3925.6 05 5 24 3954.2 05 5 25 3980.9 05 5 26 4007.8 05 5 27 4033.5 05 5 28 4035.3 05 5 29 3957.9 05 5 30 3948.2 05 5 31 3958.8 05 6 1 3973.1 05 6 2 3984.0 05 6 3 4010.9 05 6 4 4027.2 05 6 5 4040.0 05 6 6 4049.8 05 6 7 4027.3 05 6 8 4023.0 05 6 9 4033.8 05 6 10 4051.4 05 6 11 4063.6 05 6 12 4023.0 05 6 13 3998.4 05 6 14 3996.8 05 6 15 3962.9 05 6 16 3922.2 05 6 17 3919.3 05 6 18 3953.7 05 6 19 3994.4 05 6 20 4004.1 05 6 21 3999.8 05 6 22 3981.9 05 6 23 4058.7 05 6 24 4030.6 05 6 25 3999.0 05 6 26 4012.5 05 6 27 4034.3 05 6 28 4044.1 05 6 29 4042.9 05 6 30 4050.3 05 7 1 4049.5 05 7 2 4042.0 05 7 3 4055.2 05 7 4 4059.7 05 7 5 4075.2 05 7 6 4087.6 05 7 7 4083.7 05 7 8 4071.0 05 7 9 4098.5 05 7 10 4024.6 05 7 11 3967.0 05 7 12 3957.2 05 7 13 3896.8 05 7 14 3913.0 05 7 15 3928.0 05 7 16 3888.0 05 7 17 3684.0 05 7 18 3713.6 05 7 19 3820.1 05 7 20 3915.7 05 7 21 4011.0 05 7 22 4004.8 05 7 23 4003.7 05 7 24 3993.1 05 8 2 3927.9 05 8 3 3916.7 05 8 4 3950.6 05 8 5 3936.2 05 8 6 3900.1 05 8 7 3814.6 05 8 8 3861.2 05 8 9 3913.0 05 8 10 3925.0 05 8 11 3907.4 05 8 12 3943.5 05 8 13 3934.6 05 8 14 3938.9 05 8 15 3952.2 05 8 16 3956.1 05 8 17 3976.6 05 8 18 3998.5 05 8 19 4009.5 05 8 20 4007.0 05 8 21 3994.8 05 8 22 4009.2 05 8 23 4042.2 05 8 24 3942.1 05 8 25 3842.2 05 8 26 3907.3 05 8 27 3954.9 05 8 28 3967.2 05 8 29 4014.9 05 8 30 4013.2 05 8 31 3999.4 05 9 1 4007.0 05 9 2 3988.5 05 9 3 3947.2 05 9 4 3946.2 05 9 5 3945.7 05 9 6 3956.0 05 9 7 3980.1 05 9 8 4003.5 05 9 9 3975.5 05 9 10 3903.8 05 9 11 3544.0 05 9 12 3509.6 05 9 13 3463.4 05 9 14 3533.4 05 9 15 3523.9 05 9 16 3567.0 05 9 17 3657.8 05 9 18 3763.7 05 9 19 3805.4 05 9 20 3848.3 05 9 21 3874.8 05 9 22 3901.1 05 9 23 3911.2 05 9 24 3946.8 05 9 25 3927.6 05 9 26 3938.6 05 9 27 3960.8 05 9 28 3961.2 05 9 29 3981.9 05 9 30 3991.5 05 10 1 3987.1 05 10 2 4003.5 05 10 3 4026.8 05 10 4 4044.3 05 10 5 4050.2 05 10 6 4062.4 05 10 7 4069.4 05 10 8 4049.9 05 10 9 4029.4 05 10 10 3973.2 05 10 11 3984.2 05 10 12 3990.9 05 10 13 3993.2 05 10 14 4004.2 05 10 15 4020.2 05 10 16 4053.8 05 10 17 4061.6 05 10 18 4063.5 05 10 19 4075.0 05 10 20 4073.6 05 10 21 4066.7 05 10 22 4058.8 05 10 23 4059.4 05 10 24 4059.1 05 10 25 4061.5 05 10 26 4066.6 05 10 27 4065.2 05 10 28 4071.9 05 10 29 4084.9 05 10 30 4086.2 05 10 31 4063.0 05 11 1 4081.6 05 11 2 4085.7 05 11 3 4101.1 05 11 4 4098.3 05 11 5 4089.9 05 11 6 4074.5 05 11 7 4073.0 05 11 8 4067.5 05 11 9 4073.6 05 11 10 4081.2 05 11 11 4094.6 05 11 12 4092.3 05 11 13 4102.6 05 11 14 4102.3 05 11 15 4086.8 05 11 16 4095.4 05 11 17 4094.2 05 11 18 4098.9 05 11 19 4091.0 05 11 20 4075.0 05 11 21 4075.8 05 11 22 4078.8 05 11 23 4093.3 05 11 24 4095.2 05 11 25 4097.4 05 11 26 4115.8 05 11 27 4137.3 05 11 28 4129.0 05 11 29 4128.5 05 11 30 4110.6 05 12 1 4109.4 05 12 2 4102.0 05 12 3 4104.6 05 12 4 4104.4 05 12 5 4102.0 05 12 6 4111.8 05 12 7 4110.0 05 12 8 4100.3 05 12 9 4102.5 05 12 10 4113.3 05 12 11 4101.0 05 12 12 4091.2 05 12 13 4104.2 05 12 14 4101.9 05 12 15 4096.9 05 12 16 4114.7 05 12 17 4114.5 05 12 18 4081.5 05 12 19 4079.5 05 12 20 4064.9 05 12 21 4059.2 05 12 22 4062.0 05 12 23 4083.1 05 12 24 4079.7 05 12 25 4094.6 05 12 26 4117.1 05 12 27 4134.7 05 12 28 4109.2 05 12 29 4099.1 05 12 30 4098.9 05 12 31 4036.9 -------------- next part -------------- 06 1 1 4009.8 06 1 2 4048.5 06 1 3 4059.5 06 1 4 4062.8 06 1 5 4036.0 06 1 6 4070.0 06 1 7 4091.0 06 1 8 4106.6 06 1 9 4094.4 06 1 10 4082.7 06 1 11 4109.2 06 1 12 4125.5 06 1 13 4114.0 06 1 14 4122.8 06 1 15 4158.9 06 1 16 4131.8 06 1 17 4125.8 06 1 18 4119.5 06 1 19 4143.4 06 1 20 4135.2 06 1 21 4142.3 06 1 22 4160.0 06 1 23 4158.1 06 1 24 4129.6 06 1 25 4107.3 06 1 26 4122.5 06 1 27 4126.6 06 1 28 4139.3 06 1 29 4146.5 06 1 30 4147.7 06 1 31 4158.0 06 2 1 4161.2 06 2 2 4176.8 06 2 3 4168.1 06 2 4 4156.2 06 2 5 4162.3 06 2 6 4156.3 06 2 7 4149.0 06 2 8 4148.1 06 2 9 4158.5 06 2 10 4168.5 06 2 11 4165.5 06 2 12 4158.8 06 2 13 4165.3 06 2 14 4175.7 06 2 15 4193.8 06 2 16 4196.7 06 2 17 4184.2 06 2 18 4196.7 06 2 19 4210.6 06 2 20 4203.6 06 2 21 4182.5 06 2 22 4185.1 06 2 23 4189.5 06 2 24 4196.7 06 2 25 4189.9 06 2 26 4196.2 06 2 27 4184.7 06 2 28 4181.1 06 3 1 4165.6 06 3 2 4176.5 06 3 3 4181.9 06 3 4 4207.0 06 3 5 4210.1 06 3 6 4201.4 06 3 7 4225.6 06 3 8 4246.0 06 3 9 4241.9 06 3 10 4226.2 06 3 11 4231.0 06 3 12 4228.2 06 3 13 4218.3 06 3 14 4189.8 06 3 15 4182.6 06 3 16 4188.8 06 3 17 4196.0 06 3 18 4223.0 06 3 19 4256.9 06 3 20 4244.3 06 3 21 4235.2 06 3 22 4231.7 06 3 23 4225.0 06 3 24 4204.6 06 3 25 4203.4 06 3 26 4204.3 06 3 27 4199.3 06 3 28 4211.2 06 3 29 4234.9 06 3 30 4237.6 06 3 31 4238.8 06 4 1 4240.5 06 4 2 4226.4 06 4 3 4220.0 06 4 4 4217.4 06 4 5 4251.0 06 4 6 4259.8 06 4 7 4235.1 06 4 8 4208.0 06 4 9 4231.3 06 4 10 4223.7 06 4 11 4230.5 06 4 12 4221.1 06 4 13 4201.1 06 4 14 4180.2 06 4 15 4204.5 06 4 16 4207.4 06 4 17 4210.4 06 4 18 4228.1 06 4 19 4225.4 06 4 20 4225.2 06 4 21 4222.5 06 4 22 4205.3 06 4 23 4194.5 06 4 24 4218.0 06 4 25 4222.3 06 4 26 4236.2 06 4 27 4241.2 06 4 28 4225.0 06 4 29 4208.1 06 4 30 4220.9 06 5 1 4218.8 06 5 2 4235.4 06 5 3 4243.0 06 5 4 4240.8 06 5 5 4235.3 06 5 6 4231.6 06 5 7 4199.2 06 5 8 4207.1 06 5 9 4222.4 06 5 10 4222.9 06 5 11 4208.3 06 5 12 4207.4 06 5 13 4197.4 06 5 14 4198.5 06 5 15 4194.6 06 5 16 4199.0 06 5 17 4222.9 06 5 18 4202.7 06 5 19 4180.1 06 5 20 4196.4 06 5 21 4207.7 06 5 22 4211.4 06 5 23 4204.8 06 5 24 4209.5 06 5 25 4232.3 06 5 26 4256.8 06 5 27 4275.8 06 5 28 4278.2 06 5 29 4258.8 06 5 30 4237.0 06 5 31 4213.3 06 6 1 4205.3 06 6 2 4206.8 06 6 3 4211.9 06 6 4 4206.6 06 6 5 4212.2 06 6 6 4238.8 06 6 7 4234.1 06 6 8 4227.5 06 6 9 4211.9 06 6 10 4232.0 06 6 11 4234.1 06 6 12 4237.9 06 6 13 4230.1 06 6 14 4237.7 06 6 15 4236.4 06 6 16 4242.0 06 6 17 4224.0 06 6 18 4237.9 06 6 19 4236.4 06 6 20 4266.6 06 6 21 4258.6 06 6 22 4260.8 06 6 23 4260.8 06 6 24 4243.7 06 6 25 4256.6 06 6 26 4258.5 06 6 27 4260.2 06 6 28 4257.3 06 6 29 4219.6 06 7 10 4056.0 06 7 11 4031.0 06 7 12 4084.5 06 7 13 4138.8 06 7 14 4147.3 06 7 15 4169.3 06 7 16 4186.7 06 7 17 4178.3 06 7 18 4191.3 06 7 19 4190.5 06 7 20 4193.4 06 7 21 4195.9 06 7 22 4212.0 06 7 23 4226.8 06 7 24 4226.4 06 7 25 4231.7 06 7 26 4215.1 06 7 27 4224.3 06 7 28 4228.1 06 7 29 4236.0 06 7 30 4246.2 06 7 31 4234.4 06 8 1 4241.6 06 8 2 4239.1 06 8 3 4242.1 06 8 4 4256.9 06 8 5 4257.7 06 8 6 4246.9 06 8 7 4252.9 06 8 8 4233.8 06 8 9 4241.0 06 8 10 4248.0 06 8 11 4264.2 06 8 12 4262.4 06 8 13 4272.2 06 8 14 4279.8 06 8 15 4277.0 06 8 16 4267.3 06 8 17 4229.9 06 8 18 4231.0 06 8 19 4219.4 06 8 20 4155.0 06 8 21 4145.8 06 8 22 4145.9 06 8 23 4168.5 06 8 24 4189.4 06 8 25 4232.8 06 8 26 4248.0 06 8 27 4262.2 06 8 28 4256.0 06 8 29 4244.3 06 8 30 4195.8 06 8 31 4186.9 06 9 1 4201.6 06 9 2 4192.9 06 9 3 4183.0 06 9 4 4185.3 06 9 5 4186.2 06 9 6 4209.6 06 9 7 4229.2 06 9 8 4244.2 06 9 9 4241.4 06 9 10 4236.5 06 9 11 4244.0 06 9 12 4243.0 06 9 13 4260.0 06 9 14 4280.0 06 9 15 4267.3 06 9 16 4265.9 06 9 17 4268.1 06 9 18 4240.6 06 9 19 4237.8 06 9 20 4266.5 06 9 21 4279.0 06 10 13 4296.0 06 10 14 4254.3 06 10 15 4260.3 06 10 16 4283.5 06 10 17 4293.0 06 10 18 4296.2 06 10 19 4285.7 06 10 20 4265.8 06 10 21 4252.6 06 10 22 4249.2 06 10 23 4243.7 06 10 24 4262.8 06 10 25 4263.7 06 10 26 4273.5 06 10 27 4248.4 06 10 28 4254.0 06 10 29 4272.6 06 10 30 4287.8 06 10 31 4284.1 06 11 1 4288.7 06 11 2 4279.4 06 11 3 4282.1 06 11 4 4263.4 06 11 5 4269.4 06 11 6 4259.6 06 11 7 4253.5 06 11 8 4265.4 06 11 9 4283.3 06 11 11 4249.3 06 11 12 4231.2 06 11 13 4240.5 06 11 14 4263.8 06 11 15 4212.1 06 11 16 4227.0 06 11 17 4250.7 06 11 18 4265.2 06 11 19 4247.9 06 11 20 4259.6 06 11 21 4263.8 06 11 22 4239.2 06 11 23 4247.8 06 11 24 4262.9 06 11 25 4268.9 06 11 26 4282.2 06 11 27 4294.9 06 11 28 4312.2 06 11 29 4263.7 06 11 30 4289.6
Hi You did not provide enough information of what and how you want to do the plot> summary(temp)V1 V2 V3 V4 Min. :5 Min. : 1.000 Min. : 1.00 Min. :3300 1st Qu.:5 1st Qu.: 3.000 1st Qu.: 8.00 1st Qu.:3947 Median :5 Median : 6.000 Median :15.00 Median :3996 Mean :5 Mean : 6.513 Mean :15.52 Mean :3976 3rd Qu.:5 3rd Qu.:10.000 3rd Qu.:23.00 3rd Qu.:4053 Max. :5 Max. :12.000 Max. :31.00 Max. :4137> temp2<-read.table("2006.txt") > summary(temp2)V1 V2 V3 V4 Min. :6 Min. : 1.000 Min. : 1.00 Min. :4010 1st Qu.:6 1st Qu.: 3.000 1st Qu.: 9.00 1st Qu.:4190 Median :6 Median : 5.500 Median :16.00 Median :4225 Mean :6 Mean : 5.725 Mean :16.04 Mean :4213 3rd Qu.:6 3rd Qu.: 8.000 3rd Qu.:23.00 3rd Qu.:4248 Max. :6 Max. :11.000 Max. :31.00 Max. :4312>From summaries of your data you have 2 files with year no in first, monthin second, day in third and some value in fourth column. The value from year 2006 is greater than the value in 2005. For accommodating all 4.column data you need to set correct range by ylim. And if you use lines on non sorted values it can result in clump of lines. You could maybe consult ?aggregate and or ?supsmu However only you know what you want as an x values and as an y values. Regards Petr r-help-bounces at r-project.org napsal dne 07.10.2009 10:12:24:> Good morning. I wish to plot two data on the same axis. I triedplot(x,y,> type = "l") for the first and tried to use lines or points(x,y, lty = 2,col> = 4) to add or plot the second data on alongside the first. However,what I> got was not encouraging. > I have attached the two data and would be pleased if anybody could be of > help. > Thank you > Best regards > Ogbos > [p??loha 2005.txt odstran?na u?ivatelem Petr PIKAL/CTCAP] [p??loha2006.txt> odstran?na u?ivatelem Petr PIKAL/CTCAP]______________________________________________> R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Hi, Your two data sets have a different year so I'm not sure what you want to do with the x axis. The code below plots both data sets on the same graph, with a range of two years, d1 <- read.table("~/Downloads/2005.txt") d2 <- read.table("~/Downloads/2006.txt") cleanup <- function(d){ names(d) <- c("year", "month", "day", "value") transform(d, date=as.Date(paste("0", year, month, day, sep=""), "%y%m%d")) } d1 <- cleanup(d1) d2 <- cleanup(d2) d <- rbind(d1, d2) d <- transform(d, year=factor(year)) with(d, plot(date,value)) # prettier with ggplot2 library(ggplot2) qplot(date, value, data=d, colour=year) HTH, baptiste 2009/10/7 ogbos okike <ogbos.okike at gmail.com>:> Good morning. I wish to plot two data on the same axis. I tried plot(x,y, > type = "l") for the first and tried to use lines or points(x,y, lty = 2, col > = 4) to add or plot the second data on alongside the first. However, what I > got was not encouraging. > I have attached the two data and would be pleased if anybody could be of > help. > Thank you > Best regards > Ogbos > > ______________________________________________ > 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. > >
On 10/07/2009 07:12 PM, ogbos okike wrote:> Good morning. I wish to plot two data on the same axis. I tried plot(x,y, > type = "l") for the first and tried to use lines or points(x,y, lty = 2, col > = 4) to add or plot the second data on alongside the first. However, what I > got was not encouraging. > I have attached the two data and would be pleased if anybody could be of > help.Hi Ogbos, Try this: plot(oo1$daymon,oo1[,4], main="Two years of something",type="l",col="blue", ylim=c(3300,4400)) lines(oo2$daymon,oo2[,4],col="red") legend(oo1$daymon[100],3600,c("2005","2006"), col=c(4,2),lty=1) Jim