Skip to content

Commit 605f5cc

Browse files
authored
Create weather_forecast.py
由温度、风力,但是不是双y轴
1 parent 7622b0c commit 605f5cc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

matplotlib/weather_forecast.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#Author: Listen
2+
#!/usr/bin/env python3
3+
#-*- coding:utf-8 -*-
4+
5+
import matplotlib.pyplot as plt
6+
import numpy as np
7+
8+
plt.figure()
9+
#生成一个50以内的随机数列表
10+
x= [x for x in range(50)]
11+
#颜色的列表
12+
colors = ['r','y','g','b','c','m']
13+
#标志的字典
14+
legends={'circle':'o','star':'*','triangle_down':'v',
15+
'dash-dot':'-.','dashed_line':'--','x_mark':'x'}
16+
plt.yticks([y for y in range(-7,20,2)])
17+
#enumerate 列举
18+
for index,t in enumerate(legends.values()):
19+
sample_y=np.random.randn(50).cumsum()
20+
plt.plot(x,sample_y,t,color=colors[index])
21+
22+
plt.legend(legends.keys(),loc=2)
23+
plt.savefig('../savefig/mult_dot.png')
24+
plt.show()

0 commit comments

Comments
 (0)