【发布时间】:2022-01-15 21:50:49
【问题描述】:
我用 matplotlib 创建了一个小提琴图。现在,我想为最小值和最大值减少两条线的水平长度。我该怎么做?
这是我的代码。为了更好地概览,代码被简化为必要的信息。
# Initialize
import matplotlib.pyplot as plt
import numpy as np
import statistics
# Creation of violinplots
Core_values = np.loadtxt("pathtofile/xyz.txt", comments=None, delimiter=None, converters=None, skiprows=0, usecols=0,
unpack=False, ndmin=0, encoding=None, max_rows=None, like=None)
Core = plt.violinplot(Core_values, positions=[0], points=500)
# Look of the violinplot
for vp in Core["bodies"]:
vp.set_facecolor("cornflowerblue")
vp.set_zorder(2)
vp.set_alpha(1)
vp.set_linewidth(1)
for vp_part in ("cbars", "cmins", "cmaxes"):
vp = Core[vp_part]
vp.set_edgecolor("black")
plt.show()
下面的截图显示了我的意思:小提琴图的顶部和底部黑线。我想减少它们的水平长度。
【问题讨论】:
标签: python matplotlib violin-plot