Matplotlib differentiate between mean and median with colour or shape

混江龙づ霸主 提交于 2019-12-24 03:17:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!