#-*- coding:utf-8 -*- import numpy as np import matplotlib.pyplot as plt list_all = open("polar_list").readlines() count = {} count = { 0:0, 2:0, 4:0, 6:0, 8:0, 10:0, 12:0, 14:0, 16:0, 18:0, 20:0, 22:0, 24:0, 26:0 } for each in list_all: period = int(each.strip()) if period not in count.keys(): count_num = 0 count[period] = count_num elif period in count.keys(): count_num = count[period] + 1 count[period] = count_num # 绘制极坐标图 theta = np.linspace(2*np.pi, 0, 14, endpoint=False) radii = count.values() print(count) width=-0.5 ax = plt.subplot(111,projection='polar') plt.thetagrids(np.linspace(360, 0, 14, endpoint=False), [0,2,4,6,8,10,12,14,16,18,20,22,24,26]) ax.set_theta_zero_location('N') bars = ax.bar(theta,radii,width=width,bottom=0.0,align="center",alpha=0.5) plt.ylim((0, 60)) plt.show()