LoginSignup
ryota0000
@ryota0000

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

箱ひげ図の値を表示させたいです

Python初心者です。

箱ひげ図の値(平均値、最小値、中央値、外れ値など)を表示させたいです。
※平均234.12など具体的な値を図に表示させたいという意味です。

調べてはみたのですが、あまりそのような記事を見なかったのですが、表示させることは出来るのでしょうか。

表示させるコードがあれば教えていただきたいです。
(listの値で箱ひげ図を作成しています)

私のコードが必要であれば追記します。

0

1Answer

パーセンタイルをそのままグラフに書いてみました。
望んでいるものではないかもしれません。

image.png

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt

# 数学の点数
math = np.array([74, 65, 40, 62, 85, 67, 82, 71, 60, 99])

# 箱ひげ図
fig, ax = plt.subplots()

ax.boxplot(math)
ax.set_xticklabels(['math'])
percentile = np.percentile(math, q=[0, 25, 50, 75, 100])
for p in percentile:
    ax.text(1.1, p, p, va='center')
0

Your answer might help someone💌