Matplotlib

matplotlib.pyplot.violinplot(dataset, positions=None, vert=True, widths=0.5, showmeans=False, showextrema=True, showmedians=False, points=100, bw_method=None, hold=None, data=None)
参数类型描述
datasetArray or a sequence of vectors.输入数据
positionsarray-like, default = [1, 2, …, n]Sets the positions of the violins. The ticks and limits are automatically set to match the positions.
vertbool, default = True为真则垂直,为假则横向
widthsarray-like, default = 0.5Either a scalar or a vector that sets the maximal width of each violin. The default is 0.5, which uses about half of the available horizontal space.
showmeansbool, default = FalseIf True, will toggle rendering of the means.
showextremabool, default = TrueIf True, will toggle rendering of the extrema.
showmediansbool, default = FalseIf True, will toggle rendering of the medians.
pointsscalar, default = 100Defines the number of points to evaluate each of the gaussian kernel density estimations at.
bw_methodstr, scalar or callable, optionalThe method used to calculate the estimator bandwidth. This can be ‘scott’, ‘silverman’, a scalar constant or a callable. If a scalar, this will be used directly as kde.factor. If a callable, it should take a GaussianKDE instance as its only parameter and return a scalar. If None (default), ‘scott’ is used.

返回一个字典

bodies: A list of the matplotlib.collections.PolyCollection instances containing the filled area of each violin.
cmeans: A matplotlib.collections.LineCollection instance created to identify the mean values of each of the violin’s distribution.
cmins: A matplotlib.collections.LineCollection instance created to identify the bottom of each violin’s distribution.
cmaxes: A matplotlib.collections.LineCollection instance created to identify the top of each violin’s distribution.
cbars: A matplotlib.collections.LineCollection instance created to identify the centers of each violin’s distribution.
cmedians: A matplotlib.collections.LineCollection instance created to identify the median values of each of the violin’s distribution.

修改内容,因为violin图里面包含了很多图形对象,所以没有color参数来调整.需要对作图之后的返回对象来控制各个图像对象的颜色.

test = plt.violinplot(list)

len(test["bodies"])

test["bodies"][0].set_color("red")

对象的具体可参考
class matplotlib.collections.PolyCollection(verts, sizes=None, closed=True, **kwargs)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值