2
我的数据集是这样的:一个Python列表与6号[23948.30,23946.20,23961.20,23971.70,23956.30,23987.30]蟒/ matplotlib/seaborn-箱线图上的数据点的x轴
我希望他们作为x轴上方的水平方块图,其中[23855和24472]作为x轴的极限(不含y轴)。
x轴还将包含数据中的点。
(这样的箱形图和x轴具有相同的比例)
我也希望箱形图显示画面的平均数。
现在我只能得到水平方块图。 (我也想在x轴上显示整个数字,而不是XX + 2.394e)
这里是我现在的代码:
`
def box_plot(circ_list, wear_limit):
print circ_list
print wear_limit
fig1 = plt.figure()
plt.boxplot(circ_list, 0, 'rs', 0)
plt.show()
`
Seaborn代码我现在正在尝试:
def box_plot(circ_list, wear_limit):
print circ_list
print wear_limit
#fig1 = plt.figure()
#plt.boxplot(circ_list, 0, 'rs', 0)
#plt.show()
fig2 = plt.figure()
sns.set(style="ticks")
x = circ_list
y = []
for i in range(0, len(circ_list)):
y.append(0)
f, (ax_box, ax_line) = plt.subplots(2, sharex=True,
gridspec_kw={"height_ratios": (.15, .85)})
sns.boxplot(x, ax=ax_box)
sns.pointplot(x, ax=ax_line, ay=y)
ax_box.set(yticks=[])
ax_line.set(yticks=[])
sns.despine(ax=ax_line)
sns.despine(ax=ax_box, left=True)
cur_axes = plt.gca()
cur_axes.axes.get_yaxis().set_visible(False)
sns.plt.show()
非常感谢你..但这感觉就像它有很长的胡须。你能否在箱形图下添加x轴(点位于x轴上)?类似于我在海豹身上所拥有的东西? – KKlalala
它有很长的胡须,因为你的数据有很高的差异:)。要添加x轴,只需从代码中移除下面的代码:ax.spines ['bottom']。set_color('none') – Andreq
我试过了,效果不好。让我再澄清一点这个问题! – KKlalala