Python Matplotlib Box plot -
this dataframe:
{'parameter': {0: 'a', 1: 'a', 2: 'a', 3: 'a', 4: 'a', 5: 'a', 6: 'a', 7: 'a'}, 'site': {0: 's1', 1: 's2', 2: 's1', 3: 's2', 4: 's1', 5: 's2', 6: 's1', 7: 's2'}, 'value': {0: 2.3399999999999999, 1: 2.6699999999999999, 2: 2.5600000000000001, 3: 2.8900000000000001, 4: 3.4500000000000002, 5: 4.4500000000000002, 6: 3.6699999999999999, 7: 4.5599999999999996}}
i trying plot boxplot of parameter site. easiest way it? additional question if have more 1 parameter, easiest way plot boxplot using matplotlib parameter? thank you
you're going want use dataframe.boxplot
method , group "parameter" , "site" columns.
import matplotlib.pyplot plt pandas import dataframe df = dataframe({'parameter': ['a',]*8, 'site': ['s1', 's2', 's1', 's2', 's1', 's2', 's1', 's2'], 'value': [2.34, 2.67, 2.56, 2.89, 3.45, 4.45, 3.67, 4.56]}) df.boxplot(by=['parameter', 'site']) plt.show()
if want plot specific column of data, can use column
keyword argument boxplot
.
# plot single value df.boxplot(column='value', by=['parameter', 'site']) # plot multiple values df.boxplot(column=['value', 'othervalue'], by=['parameter', 'site'])
Comments
Post a Comment