Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- SNR = {}
- file = open('SNR.txt', 'r')
- for line in file:
- s = line.split()
- if len(s) > 1 and s[8] != "0.0":
- num = s[4]
- dot_time = s[8]
- time = float(dot_time)
- if num not in SNR.keys():
- SNR[num] = [time]
- elif num in SNR.keys():
- SNR[num].append(time)
- sorted_SNR = {key: SNR[key] for key in sorted(SNR)}
- print('Введите SNR для демонстрации: ' + ', '.join(sorted_SNR.keys()) + '\n')
- num_of_snr = input()
- times = sorted_SNR[num_of_snr]
- dict_of_times = {key: 0 for key in set(times)}
- counts = []
- for key in dict_of_times:
- dict_of_times[key] = times.count(key)
- counts.append(dict_of_times[key])
- plt.bar(dict_of_times.keys(), counts, width=0.6)
- plt.xlabel('Время')
- plt.ylabel('Кол-во повторений')
- #plt.show()
- plt.title('SNR%s' % num_of_snr)
- plt.savefig('SNR%s.png' % num_of_snr)
- plt.show()
Add Comment
Please, Sign In to add comment