Skip to content

Commit 460d461

Browse files
authored
Create polar.py
画一个极坐标的花瓣图
1 parent a9dc256 commit 460d461

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

matplotlib/polar.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/ env python3
2+
#coding = utf-8
3+
import matplotlib.pyplot as plt
4+
import numpy as np
5+
6+
#主要使用plt选择对象
7+
8+
#定义函数
9+
x = np.linspace(-10*np.pi,10*np.pi,1000 )
10+
r = 2-2*np.sin(5*x )
11+
12+
#定义画布,绘制图像,polar指定极坐标
13+
ax1 = plt.subplot(projection='polar')
14+
ax1.plot(x,r,label=u'flower',color='red', linewidth=1)
15+
16+
#显示图例
17+
plt.legend(loc=3)
18+
19+
#设置图表标题
20+
plt.title(u'$r=2-2\sin(5x)$')
21+
#plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
22+
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
23+
24+
plt.savefig('../savefig/polar.png')
25+
plt.show()

0 commit comments

Comments
 (0)