===玫瑰图/极地坐标直方图=== [[https://matplotlib.org/stable/gallery/pie_and_polar_charts/polar_bar.html#sphx-glr-gallery-pie-and-polar-charts-polar-bar-py]] {{:个性化条目:polar_x202sc21071506-z01-f006.png?400|}} #-*- coding:utf-8 -*- import numpy as np import matplotlib.pyplot as plt list_all = open("polar_list").readlines() count = {} 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 = [0,2,4,6,8,10,12,14,16,18,20,22,24,26] theta = np.linspace(2*np.pi, 0, 14, endpoint=False) radii = count.values() 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",tick_label=None) #labels=["","","","","","",""] #bars = ax.bar(labels,theta,radii,width=width,bottom=0.0,align="center") # theta指定扇形起始角度位置,radii指定扇形的半径, # width指定扇形的角度, # bottom可以指定扇形从是否裁去圆心处的部分 plt.show()