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