为了账号安全,请及时绑定邮箱和手机立即绑定

如何添加第二个(圆形)直方图从csv文件中读取?

如何添加第二个(圆形)直方图从csv文件中读取?

HUX布斯 2021-05-30 20:08:34
我是 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
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 248 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信