我是 python 新手,拼凑了一些从 .csv 文件的第一个索引(包含弧度值)读取的代码,并绘制了直方图和圆形直方图。我想添加从第二个索引读取的第二个(圆形)直方图。谁能告诉我如何做到这一点?完整代码:import numpy as npimport matplotlib.pyplot as pltimport csvwith open('radians.csv', 'r') as f: reader=csv.reader(f) angles=[] # Initialise empty list next(reader) # Skip header line for row in reader: angle = float(row[0]) angles.append(angle)bins_number = 18 # the [-180, 180) interval will be subdivided into thisbins = np.linspace(-np.pi, np.pi, bins_number + 1)n, _, _ = plt.hist(angles, bins) # Create histogramplt.show()# Create circular histogramplt.clf()width = 2 * np.pi / bins_numberax = plt.subplot(1, 1, 1, projection='polar')bars = ax.bar(bins[:bins_number], n, width=width, bottom=10.0, align='edge', color='red')for bar in bars: bar.set_alpha(0.5)plt.show()rostral.csv 值示例:1.214109733,2.6780662271.214109733,2.3784080711.214109733,2.3784080711.290159115,2.3149061.193219453,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.314906-1.7325846,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.208196994,2.3149061.248951138,2.3149060.945157766,2.314906-1.343997479,2.314906-1.561624822,2.314906-1.903895159,2.314906
添加回答
举报
0/150
提交
取消