码迷,mamicode.com
首页 > 其他好文 > 详细

matplotlib学习之散点图

时间:2017-10-03 23:35:06      阅读:606      评论:0      收藏:0      [点我收藏+]

标签:vol   utf-8   blog   hang   span   ret   11.2   nump   row   

1.任务

a.绘制股票跌涨前一天和今天是否有相关性的散点图,并设置散点图的常用属性

b.绘制股票开盘价和最高价前一天和今天是否有相关性的散点图,并设置散点图的常用属性

2.资源文件(000001.csv)

Date,Open,High,Low,Close,Turnover,Volume
1/5/2015,3258.63,3369.28,3253.88,3350.52,549760.13,53135238400
1/6/2015,3330.8,3394.22,3303.18,3351.45,532398.46,50166169600
1/7/2015,3326.65,3374.9,3312.21,3373.95,436416.7,39191888000
1/8/2015,3371.96,3381.57,3285.1,3293.46,399230.3,37113116800
1/9/2015,3276.97,3404.83,3267.51,3285.41,458648,41024086400
1/12/2015,3258.21,3275.19,3191.58,3229.32,366273.06,32206467200
1/13/2015,3223.54,3259.39,3214.41,3235.3,273588.77,23072576000
1/14/2015,3242.34,3268.48,3193.98,3222.44,267204.53,24019075200
1/15/2015,3224.07,3337.08,3207.54,3336.46,330610.53,28254624000
1/16/2015,3343.6,3400.32,3340.49,3376.5,392253.89,33987676800
1/19/2015,3189.73,3262.21,3095.07,3116.35,409885.98,40109878400
1/20/2015,3114.56,3190.25,3100.48,3173.05,416295.2,35708080000
1/21/2015,3189.09,3337,3178.34,3323.61,473758.66,41095603200
1/22/2015,3327.32,3352.38,3293.98,3343.34,407874.08,35338297600
1/23/2015,3357.1,3406.79,3328.29,3351.76,420979.52,36624924800
1/26/2015,3347.26,3384.8,3321.31,3383.18,358427.46,31754099200
1/27/2015,3389.85,3390.22,3290.22,3352.96,418298.88,37451753600
1/28/2015,3325.72,3354.8,3294.66,3305.74,341564.29,30192710400
1/29/2015,3259,3286.79,3234.24,3262.3,296424.51,27465862400
1/30/2015,3273.75,3288.5,3210.31,3210.36,284265.66,25831254400
2/2/2015,3148.14,3175.13,3122.57,3128.3,266849.97,25086163200
2/3/2015,3156.09,3207.94,3129.73,3204.91,283355.97,24819216000
2/4/2015,3212.82,3238.98,3171.14,3174.13,290155.17,24909808000
2/5/2015,3251.21,3251.21,3135.82,3136.53,348266.94,30613929600
2/6/2015,3120.09,3129.54,3052.94,3075.91,266502.78,24674966400
2/9/2015,3063.51,3119.03,3049.11,3095.12,240719.68,20610838400
2/10/2015,3090.49,3142.1,3084.25,3141.59,225084.91,19381713600
2/11/2015,3145.76,3166.42,3139.05,3157.7,210862.54,17284009600
2/12/2015,3157.96,3181.77,3134.24,3173.42,229691.58,19459230400
2/13/2015,3186.81,3237.16,3182.79,3203.83,293017.66,26129043200
2/16/2015,3206.14,3228.85,3195.88,3222.36,265950.69,22379742400
2/17/2015,3230.88,3255.73,3230.77,3246.91,263340.05,22833262400
2/25/2015,3256.48,3257.22,3215.55,3228.84,265143.34,23334809600
2/26/2015,3222.15,3300.62,3202.19,3298.36,334347.49,30126387200
2/27/2015,3296.83,3324.55,3291.01,3310.3,335019.58,29916371200
3/2/2015,3332.72,3336.76,3298.67,3336.28,410259.55,34644566400
3/3/2015,3317.7,3317.7,3260.43,3263.05,441593.47,38204460800
3/4/2015,3264.18,3286.59,3250.48,3279.53,346789.76,29363952000
3/5/2015,3264.09,3266.64,3221.67,3248.48,373580,32066358400
3/6/2015,3248.04,3266.93,3234.53,3241.19,328344.16,28291577600
3/9/2015,3224.31,3307.7,3198.37,3302.41,359927.52,32149542400
3/10/2015,3289.09,3309.92,3277.1,3286.07,329955.97,28581756800
3/11/2015,3289.59,3325.05,3278.47,3290.9,327573.06,28298553600
3/12/2015,3314.81,3360.05,3300.49,3349.32,407192.38,35729510400
3/13/2015,3359.49,3391.25,3352.15,3372.91,374041.41,32841014400
3/16/2015,3391.16,3449.3,3377.09,3449.3,479355.3,39913241600
3/17/2015,3469.6,3504.12,3459.69,3502.85,601500.67,52093952000
3/18/2015,3510.5,3577.66,3503.85,3577.3,617366.98,54521715200
3/19/2015,3576.02,3600.68,3546.84,3582.27,612249.66,53734662400
3/20/2015,3587.08,3632.34,3569.38,3617.32,651771.97,51666166400
3/23/2015,3640.1,3688.25,3635.49,3687.73,661574.59,53606284800
3/24/2015,3692.57,3715.87,3600.7,3691.41,754884.74,63955468800
3/25/2015,3680.95,3693.15,3634.56,3660.73,645498.94,52188633600
3/26/2015,3641.94,3707.32,3615.01,3682.1,619515.58,48864720000
3/27/2015,3686.13,3710.48,3656.83,3691.1,509298.46,40894515200
3/30/2015,3710.61,3795.94,3710.61,3786.57,692125.38,56470233600
3/31/2015,3822.99,3835.57,3737.04,3747.9,721294.98,56167603200
4/1/2015,3748.34,3817.08,3742.21,3810.29,592418.3,44745830400
4/2/2015,3827.69,3835.45,3775.89,3825.78,632028.93,47929968000
4/3/2015,3803.38,3864.41,3792.21,3863.93,635651.33,47303331200
4/7/2015,3899.42,3961.67,3891.73,3961.38,746424,57044755200
4/8/2015,3976.53,4000.22,3903.65,3994.81,839159.3,61808544000
4/9/2015,4006.13,4016.4,3900.03,3957.53,816710.91,58517683200
4/10/2015,3947.49,4040.35,3929.32,4034.31,668504.19,48428361600
4/13/2015,4072.72,4128.07,4057.29,4121.71,781667.33,58981420800
4/14/2015,4125.78,4168.35,4091.26,4135.56,814645.18,61068352000
4/15/2015,4135.65,4175.49,4069.01,4084.16,773125.89,61300582400
4/16/2015,4055.92,4195.31,4031.24,4194.82,712082.43,55124294400
4/17/2015,4254.72,4317.22,4238.91,4287.3,915633.02,70170617600
4/20/2015,4301.35,4356,4190.68,4217.08,1147600.64,85713280000
4/21/2015,4212.19,4294.38,4188.57,4293.62,862447.81,63447065600
4/22/2015,4304.6,4400.19,4297.95,4398.49,976876.99,68030508800
4/23/2015,4414.48,4444.41,4358.84,4414.51,963024.96,66734464000
4/24/2015,4355.95,4416.38,4318.12,4393.69,916872.96,62855500800
4/27/2015,4441.93,4529.73,4441.93,4527.4,975242.11,67108851200
4/28/2015,4527.63,4572.39,4432.9,4476.21,1061172.1,76767641600
4/29/2015,4446.12,4499.94,4398.64,4476.62,752401.79,51983420800
4/30/2015,4483.01,4507.34,4441.05,4441.65,774349.18,52672796800
5/4/2015,4441.34,4487.57,4387.43,4480.46,717540.8,49417340800
5/5/2015,4479.85,4488.87,4282.24,4298.71,805566.08,57285862400
5/6/2015,4311.64,4376.35,4187.37,4229.27,716536.19,48173299200
5/7/2015,4197.9,4213.76,4108.01,4112.21,540206.27,39456665600
5/8/2015,4152.98,4206.86,4099.04,4205.92,559648.64,39742809600
5/11/2015,4231.27,4334.88,4187.82,4333.58,715246.59,48875052800
5/12/2015,4342.37,4402.31,4317.98,4401.22,793463.74,52186640000
5/13/2015,4402.38,4415.63,4342.48,4375.76,780754.94,51049046400
5/14/2015,4372.82,4397.75,4329.04,4378.31,669882.3,44907792000
5/15/2015,4366.82,4366.82,4278.55,4308.69,665965.63,43970620800
5/18/2015,4277.9,4324.83,4260.51,4283.49,594559.49,38005744000
5/19/2015,4285.78,4418.4,4285.78,4417.55,693812.61,43673523200
5/20/2015,4434.98,4520.54,4432.28,4446.29,806080.51,51410620800
5/21/2015,4456.44,4530.48,4438.26,4529.42,729080.64,46499651200
5/22/2015,4584.98,4658.27,4562.99,4657.6,1007173.25,65559129600
5/25/2015,4660.08,4814.67,4656.83,4813.8,1079295.62,68246137600
5/26/2015,4854.85,4911.69,4779.08,4910.9,1138509.31,70489280000
5/27/2015,4932.85,4958.16,4857.06,4941.71,1116261.76,68116537600
5/28/2015,4943.74,4986.5,4614.24,4620.27,1247926.02,78296460800
5/29/2015,4603.46,4698.19,4431.56,4611.74,955365.57,61126240000
6/1/2015,4633.1,4829.5,4615.23,4828.74,934455.49,59338905600
6/2/2015,4844.7,4911.57,4797.55,4910.53,998745.73,62374809600
6/3/2015,4924.38,4942.06,4822.44,4909.98,1010179.9,61145382400
6/4/2015,4912.94,4947.96,4647.41,4947.1,1052270.21,67495238400
6/5/2015,5016.09,5051.63,4898.07,5023.1,1232300.67,77224083200
6/8/2015,5045.69,5146.95,4997.48,5131.88,1309924.48,85503507200
6/9/2015,5145.98,5147.45,5042.96,5113.53,1150808.58,72989382400
6/10/2015,5049.2,5164.16,5001.49,5106.04,1005432.26,59696902400
6/11/2015,5101.44,5122.46,5050.76,5121.59,974665.79,56399052800
6/12/2015,5143.34,5178.19,5103.4,5166.35,1060164.61,62562784000
6/15/2015,5174.42,5176.79,5048.74,5062.99,1064987.71,63780396800
6/16/2015,5004.41,5029.68,4842.1,4887.43,895413.95,55080140800
6/17/2015,4890.55,4983.66,4767.22,4967.9,830252.8,53710118400
6/18/2015,4942.52,4966.77,4780.87,4785.36,785831.81,50744089600
6/19/2015,4689.93,4744.08,4476.5,4478.36,685373.82,45268963200
6/23/2015,4471.61,4577.94,4264.77,4576.49,693468.22,47352614400
6/24/2015,4604.58,4691.77,4552.13,4690.15,814979.9,54300371200
6/25/2015,4711.76,4720.7,4483.55,4527.78,865372.61,57279750400
6/26/2015,4399.93,4456.9,4139.53,4192.87,787653.44,56521785600
6/29/2015,4289.77,4297.47,3875.05,4053.03,894482.3,67378636800
6/30/2015,4006.75,4279.97,3847.88,4277.22,924607.87,70917664000
7/1/2015,4214.15,4317.05,4043.37,4053.7,819002.62,59876940800
7/2/2015,4058.62,4080.39,3795.25,3912.77,724185.79,58601561600
7/3/2015,3793.71,3927.13,3629.56,3686.92,634413.25,54816313600
7/6/2015,3975.21,3975.21,3653.04,3775.91,926339.58,83113926400
7/7/2015,3654.78,3750.57,3585.4,3727.12,767003.58,69881868800
7/8/2015,3467.4,3599.25,3421.53,3507.19,698169.92,68035692800
7/9/2015,3432.45,3748.48,3373.54,3709.33,660375.23,65691462400
7/10/2015,3707.46,3959.22,3677.43,3877.8,679294.78,58636422400
7/13/2015,3918.99,4030.19,3858.64,3970.39,781804.54,64348902400
7/14/2015,3958.37,4035.43,3855.56,3924.49,830071.94,67055878400
7/15/2015,3874.97,3914.27,3741.25,3805.7,700536.51,60130131200
7/16/2015,3758.5,3877.51,3688.44,3823.18,569858.94,49225619200
7/17/2015,3831.42,3994.48,3814.15,3957.35,593067.01,48172627200
7/20/2015,3948.42,4021.33,3927.12,3992.11,688255.55,53910668800
7/21/2015,3939.9,4041.82,3912.8,4017.67,646416.83,50428803200
7/22/2015,3996.43,4042.34,3960.86,4026.04,678831.94,52073222400
7/23/2015,4022.27,4132.61,4019.04,4123.92,743531.9,56358598400
7/24/2015,4124.75,4184.45,4044.83,4070.91,843022.08,62742483200
7/27/2015,3985.57,4051.16,3720.44,3725.56,721298.11,55600326400
7/28/2015,3573.14,3762.53,3537.36,3663,685057.54,56333004800
7/29/2015,3689.82,3792.07,3612.06,3789.17,557491.97,43435209600
7/30/2015,3773.79,3844.37,3685.96,3705.77,615977.92,45794323200
7/31/2015,3655.67,3729.51,3620.17,3663.73,460472.26,35095574400
8/3/2015,3614.99,3648.94,3549.5,3622.91,445991.58,36396873600
8/4/2015,3621.86,3757.03,3601.29,3756.54,464036.26,36290166400
8/5/2015,3745.65,3782.35,3676.39,3694.57,483850.27,36642297600
8/6/2015,3625.5,3710.57,3614.74,3661.54,357515.14,27407465600
8/7/2015,3692.61,3756.74,3686.3,3744.2,445485.02,34075718400
8/10/2015,3786.03,3943.62,3775.85,3928.42,652622.02,49730432000
8/11/2015,3928.81,3970.34,3891.18,3927.91,712289.92,53892345600
8/12/2015,3881.23,3937.77,3871.14,3886.32,597050.24,44268828800
8/13/2015,3869.91,3955.79,3838.16,3954.56,578685.5,43007331200
8/14/2015,3976.41,4000.68,3939.84,3965.34,647466.5,46798822400
8/17/2015,3947.84,3994.54,3907.4,3993.67,626327.68,46043206400
8/18/2015,3999.13,4006.34,3743.39,3748.16,722467.26,54377081600
8/19/2015,3646.8,3811.43,3558.38,3794.11,599513.28,47539622400
8/20/2015,3754.57,3788.01,3663.61,3664.29,501195.01,39006307200
8/21/2015,3609.96,3652.84,3490.54,3507.74,450616.48,36992048000
8/24/2015,3373.48,3388.36,3191.88,3209.91,358818.88,33467180800
8/25/2015,3004.13,3123.03,2947.94,2964.97,358735.78,35232512000
8/26/2015,2980.79,3092.04,2850.71,2927.29,461788.99,46669964800
8/27/2015,2978.03,3085.42,2906.49,3083.59,404289.31,40030838400
8/28/2015,3125.26,3235.84,3102.95,3232.35,474631.01,44313692800
8/31/2015,3203.56,3207.86,3109.16,3205.99,431068.61,39743139200
9/1/2015,3157.83,3180.33,3053.74,3166.62,420411.62,43243248000
9/2/2015,3027.68,3194.48,3019.09,3160.17,423262.37,43817014400
9/7/2015,3149.38,3217.58,3066.3,3080.42,302689.73,29646812800
9/8/2015,3054.44,3174.71,3011.12,3170.45,263910.38,25541547200
9/9/2015,3182.55,3256.74,3165.7,3243.09,412991.42,37532796800
9/10/2015,3190.55,3243.28,3178.9,3197.89,299581.09,27326176000
9/11/2015,3189.48,3223.76,3163.45,3200.23,252769.47,22455782400
9/14/2015,3221.17,3229.48,3049.23,3114.8,373576.8,34663116800
9/15/2015,3043.8,3081.7,2983.92,3005.17,243904.59,24919444800
9/16/2015,2998.04,3182.93,2983.54,3152.26,281992.26,27752451200
9/17/2015,3131.98,3204.7,3085.31,3086.06,337393.28,31760288000
9/18/2015,3100.28,3122.05,3070.34,3097.92,218442.43,20917539200
9/21/2015,3072.09,3159.88,3060.86,3156.54,259796.67,23989736000
9/22/2015,3161.32,3213.48,3152.48,3185.62,305071.33,27478614400
9/23/2015,3137.72,3164.04,3104.74,3115.89,257560.03,23632267200
9/24/2015,3126.49,3151.16,3109.69,3142.69,231369.06,21288772800
9/25/2015,3130.85,3149.95,3063,3092.35,248971.12,23626387200
9/28/2015,3085.57,3103.07,3042.31,3100.76,166422.4,15672753600
9/29/2015,3055.22,3068.3,3021.16,3038.14,169686.59,16322267200
9/30/2015,3052.84,3073.3,3039.74,3052.78,156569.2,14664244800
10/8/2015,3156.07,3172.28,3133.13,3143.36,258830.34,23427604800
10/9/2015,3146.64,3192.72,3137.79,3183.15,256379.12,23485144000
10/12/2015,3193.54,3318.71,3188.41,3287.66,435541.02,38629472000
10/13/2015,3262.16,3298.63,3253.25,3293.23,334806.11,29715312000
10/14/2015,3280.02,3307.32,3256.25,3262.44,330277.5,29507772800
10/15/2015,3255.03,3338.3,3254.39,3338.07,362565.57,31628384000
10/16/2015,3358.3,3393.02,3334.85,3391.35,459447.81,39546057600
10/19/2015,3401.63,3423.4,3355.57,3386.7,453303.62,37811219200
10/20/2015,3377.55,3425.52,3357.86,3425.33,383582.53,31897376000
10/21/2015,3428.56,3447.26,3265.44,3320.68,518509.22,45845542400
10/22/2015,3292.29,3373.78,3282.99,3368.74,375452,32373932800
10/23/2015,3377.55,3422.02,3360.22,3412.43,425263.07,34737286400
10/26/2015,3448.65,3457.52,3402,3429.58,453942.5,36556086400
10/27/2015,3409.14,3441.57,3332.62,3434.34,408887.23,32817276800
10/28/2015,3417.01,3439.76,3367.23,3375.2,361656.19,29352329600
10/29/2015,3387.77,3411.71,3362.51,3387.32,294508.42,23567601600
10/30/2015,3380.28,3417.2,3346.59,3382.56,307266.78,24359512000
11/2/2015,3337.58,3391.06,3322.31,3325.08,286019.33,23095113600
11/3/2015,3330.32,3346.27,3302.18,3316.7,244360.56,19289744000
11/4/2015,3325.62,3459.65,3325.62,3459.64,426104.38,33907875200
11/5/2015,3459.22,3585.66,3455.53,3522.82,678674.62,55325497600
11/6/2015,3514.44,3596.38,3508.83,3590.03,543282.18,42916704000
11/9/2015,3588.5,3673.76,3588.5,3646.88,636184.06,50301670400
11/10/2015,3617.4,3669.53,3607.89,3640.49,560055.1,42974659200
11/11/2015,3635,3654.88,3605.62,3650.25,467822.21,36097267200
11/12/2015,3656.82,3659.31,3603.23,3632.9,482832.61,36171760000
11/13/2015,3600.76,3632.56,3564.81,3580.84,468668.64,34587094400
11/16/2015,3522.46,3607.61,3519.42,3606.96,369421.86,27618704000
11/17/2015,3629.98,3678.27,3598.07,3604.8,521520.35,38357545600
11/18/2015,3605.06,3617.07,3558.7,3568.47,392338.75,29758073600
11/19/2015,3573.78,3618.21,3561.04,3617.06,328442.62,24791558400
11/20/2015,3620.79,3640.53,3607.92,3630.5,413910.88,31080198400
11/23/2015,3630.87,3654.75,3598.87,3610.32,414148.22,31599747200
11/24/2015,3602.89,3616.48,3563.1,3616.11,327758.53,24881051200
11/25/2015,3614.07,3648.37,3607.52,3647.93,380802.91,27302486400
11/26/2015,3659.57,3668.38,3629.86,3635.55,426247.42,30676160000
11/27/2015,3616.54,3621.9,3412.43,3436.3,464311.26,35428752000
11/30/2015,3433.86,3470.37,3327.81,3445.4,387503.65,30419788800
12/1/2015,3442.44,3483.41,3417.54,3456.31,330256.74,25239075200
12/2/2015,3450.28,3538.85,3427.66,3536.91,369183.04,30149148800
12/3/2015,3525.73,3591.73,3517.23,3584.82,338859.1,28111123200
12/4/2015,3558.15,3568.97,3510.41,3524.99,315150.24,25173641600
12/7/2015,3529.81,3543.95,3506.62,3536.93,277503.71,20830257600
12/8/2015,3518.65,3518.65,3466.79,3470.07,296529.98,22436731200
12/9/2015,3462.58,3495.7,3454.88,3472.44,263710.98,19569884800
12/10/2015,3469.81,3503.65,3446.27,3455.5,276368.22,20042752000
12/11/2015,3441.6,3455.55,3410.92,3434.58,243081.74,18290888000
12/14/2015,3403.51,3521.78,3399.28,3520.67,277813.28,21537462400
12/15/2015,3518.13,3529.96,3496.85,3510.35,276274.94,20047134400
12/16/2015,3522.09,3538.69,3506.29,3516.19,265288.64,19348230400
12/17/2015,3533.63,3583.41,3533.63,3580,381439.62,28385648000
12/18/2015,3574.94,3614.7,3568.16,3578.96,365385.82,27370790400
12/21/2015,3568.58,3651.06,3565.75,3642.47,398316.96,29984928000
12/22/2015,3645.99,3652.64,3616.87,3651.77,360846.05,26117875200
12/23/2015,3653.28,3684.57,3633.02,3636.09,419902.91,29820179200
12/24/2015,3631.31,3640.22,3572.28,3612.49,315421.25,22778521600
12/25/2015,3614.05,3635.26,3601.74,3627.91,274660.06,19845112000
12/28/2015,3635.77,3641.59,3533.78,3533.78,369042.82,26998326400
12/29/2015,3528.4,3547.13,3515.52,3518.76,103096.7,7505131100

3.源代码

  a

# coding:utf-8

from  matplotlib import pyplot as plt
import numpy as np
from matplotlib import markers

open_, close_ = np.loadtxt(‘000001.csv‘, delimiter=‘,‘, skiprows=1, unpack=True, usecols=(1, 4))
change = close_ - open_
yesterday = change[:-1]
today = change[1:]
plt.scatter(yesterday, today, s=100, c=‘blue‘, marker=markers.CARETDOWNBASE,alpha=0.5)
plt.plot()
plt.show()

  b

# coding:utf-8

from  matplotlib import pyplot as plt
import numpy as np
from matplotlib import markers

open_, high = np.loadtxt(‘000001.csv‘, delimiter=‘,‘, skiprows=1, usecols=(1, 2), unpack=True)

diff = high - open_
yesterday = diff[:-1]
today = diff[1:]
plt.scatter(today, yesterday, s=100, c=‘blue‘, marker=markers.CARETDOWNBASE, alpha=0.5)
plt.plot()
plt.show()

 marker属性的常用类型

 

matplotlib学习之散点图

标签:vol   utf-8   blog   hang   span   ret   11.2   nump   row   

原文地址:http://www.cnblogs.com/jasonhaven/p/7624718.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!