This is how you could color your plot in python using matplotlib library.. Basically, we should pass
patch_artist=True
to boxplot
:import matplotlib.pyplot as plt
import numpy as np
data = [np.random.normal(0, std, 1000) for std in range(1, 6)]
plt.boxplot(data, notch=True, patch_artist=True)
plt.show()
If you'd like to control the color, do something similar to this:
import matplotlib.pyplot as plt
import numpy as np
data = [np.random.normal(0, std, 1000) for std in range(1, 6)]
box = plt.boxplot(data, notch=True, patch_artist=True)
colors = ['cyan', 'lightblue', 'lightgreen', 'tan', 'pink']
for patch, color in zip(box['boxes'], colors):
patch.set_facecolor(color)
plt.show()
Thanks for sharing this pretty post, it was good and helpful. Share more like this.
ReplyDeleteccna Training in Chennai
Python Training in Chennai
R Programming Training in Chennai
AWS Training in Chennai
DevOps Training in Chennai
Angularjs Training in Chennai
RPA Training in Chennai
Data Science Course in Chennai