Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import csv
- import numpy as np
- import matplotlib.pyplot as plt
- import matplotlib.lines as mlines
- def csv_to_list(file):
- with open(file, 'r') as f:
- reader = csv.reader(f)
- data = list(map(float, list(reader)[0]))
- return data
- def main(argv):
- boxplot_data = []
- for arg in argv:
- boxplot_data.append(csv_to_list(arg))
- temperature = [0.0, 30.0, 50.0, 100.0]
- fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(30, 30))
- box = plt.boxplot(boxplot_data, vert=False, patch_artist=True, widths=0.35)
- plt.rcParams.update({'font.size': 16, 'axes.titleweight': 'bold'})
- colors = ['orange', 'magenta', 'yellowgreen']
- for patch, color in zip(box['boxes'], colors):
- patch.set_facecolor(color)
- ax.yaxis.grid(True)
- ax.set_title('Zależność wielkości cząstek od temperatury')
- ax.set_xlabel('Wielkość [nm]')
- ax.set_ylabel('Temperatura [°C]')
- plt.xlim([0.00, 4.3])
- plt.xticks(np.arange(0, 4.3, 0.1))
- plt.boxplot(boxplot_data, 0, 'rD', 0, 0.6)
- plt.yticks(np.arange(4), temperature)
- for label in ([ax.xaxis.label, ax.yaxis.label]):
- label.set_fontsize(16)
- for label in (ax.get_xticklabels() + ax.get_yticklabels()):
- label.set_fontsize(10)
- lines = []
- for i, color in enumerate(colors):
- lines.append(mlines.Line2D([], [], color=color, marker='_',
- markersize=8, label=f'próbki nr {i+1}'))
- plt.legend(handles=lines, loc='lower right')
- plt.grid(True)
- plt.show()
- if __name__ == '__main__':
- main(sys.argv[1:])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement