问题
I am using matplotlib version 1.4.3 and I wanted to make a Violinplot and I wanted to show the mean and the median, which is easy to do but I want to mark the mean and median so they can easily be distinguished between, by changing the colour and/or shape of one of them but I cannot see anything in the documentation that allows for that.
Anyhelp would be greatly appreciated.
violinplot(x, showmeans=True, showmedians=False, widths=1.0, showextrema=False)
Example Violinplot with means and medians:
回答1:
Hint: when looking at a method's docstring never miss the Returns
part.
data = np.random.weibull(1.5, size=(1000, 3))
r = plt.violinplot(dataset=data, showmeans=True, showmedians=True,
widths=1.0, showextrema=False)
r['cmeans'].set_color('b')
r['cmedians'].set_color('g')
来源:https://stackoverflow.com/questions/35711151/matplotlib-differentiate-between-mean-and-median-with-colour-or-shape