ナビゲーション

v2.1.0
分布

箱ひげ図

複数のグループのばらつきを、箱と中央値、ひげで表す 5 つの値で比較します。

このページの内容

箱ひげ図は、各グループの観測値を 5 つの値に要約し、複数のグループを一度に比較できるようにします。箱は第 1 四分位数から第 3 四分位数まで伸び、中央値の位置に背景色の線が入ります。ひげは箱の両端から四分位範囲の 1.5 倍以内にある観測値の最小値と最大値まで伸びます。その範囲を外れる観測値は、個別の点として表示します。

箱ひげ図

<div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Latency</h3>    <p class="card-description">By region, in milliseconds</p>  </div>  <figure class="chart" id="spread-by-region"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('spread-by-region'), {  type: 'box',  label: 'Latency by region, in milliseconds',  series: [    { name: 'Tokyo', values: [38, 41, 42, 44, 45, 47, 48, 49, 52, 55, 58, 96] },    { name: 'Frankfurt', values: [52, 56, 58, 60, 61, 63, 64, 66, 69, 72, 75] },    { name: 'Virginia', values: [61, 68, 71, 74, 75, 78, 80, 83, 85, 88, 92, 140, 150] }  ]})})</script><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { Chart } from './ui/chart'<div className="card max-w(560) mx-auto">  <div className="card-header">    <h3 className="card-title">Latency</h3>    <p className="card-description">By region, in milliseconds</p>  </div>  <Chart    id="spread-by-region"    type="box"    label="Latency by region, in milliseconds"    series={[      { name: 'Tokyo', values: [38, 41, 42, 44, 45, 47, 48, 49, 52, 55, 58, 96] },      { name: 'Frankfurt', values: [52, 56, 58, 60, 61, 63, 64, 66, 69, 72, 75] },      { name: 'Virginia', values: [61, 68, 71, 74, 75, 78, 80, 83, 85, 88, 92, 140, 150] }    ]}  /></div>
<script>  import Chart from './ui/Chart.svelte'</script><div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Latency</h3>    <p class="card-description">By region, in milliseconds</p>  </div>  <Chart    id="spread-by-region"    type="box"    label="Latency by region, in milliseconds"    series={[      { name: 'Tokyo', values: [38, 41, 42, 44, 45, 47, 48, 49, 52, 55, 58, 96] },      { name: 'Frankfurt', values: [52, 56, 58, 60, 61, 63, 64, 66, 69, 72, 75] },      { name: 'Virginia', values: [61, 68, 71, 74, 75, 78, 80, 83, 85, 88, 92, 140, 150] }    ]}  /></div>
<script setup>import Chart from './ui/Chart.vue'</script><template>  <div class="card max-w(560) mx-auto">    <div class="card-header">      <h3 class="card-title">Latency</h3>      <p class="card-description">By region, in milliseconds</p>    </div>    <Chart      id="spread-by-region"      type="box"      label="Latency by region, in milliseconds"      :series="[        { name: 'Tokyo', values: [38, 41, 42, 44, 45, 47, 48, 49, 52, 55, 58, 96] },        { name: 'Frankfurt', values: [52, 56, 58, 60, 61, 63, 64, 66, 69, 72, 75] },        { name: 'Virginia', values: [61, 68, 71, 74, 75, 78, 80, 83, 85, 88, 92, 140, 150] }      ]"    />  </div></template>

各系列が 1 つのグループに対応します。観測値をそのまま values に渡すと、箱の下にグループ名が表示されます。軸の範囲は観測値に合わせて決まり、ゼロを起点にしません。値表示では 5 つの値が図の上から順に並び、words で各項目の名前をページの言語に合わせて設定できます。指定する項目は { min, q1, median, q3, max } です。horizontal を設定すると、箱が横向きになります。

箱ひげ図では、5 つの値の間の分布の形が見えないため、山が 2 つある分布と、山が 1 つだけの分布が同じように見えることがあります。分布の形が重要な場合は、グループごとにヒストグラムを描きます。

#オプション

オプション既定
labelなしグラフが示す内容と単位。描画領域のアクセシブル名になります
series[]各系列に name と、グラフ形式に応じた values、value、points、ranges、children のいずれかを指定します。category、type、low と high、リングの max は任意です
horizontalfalse棒、範囲、ダンベル、箱ひげを横向きに描画します
words英語箱ひげ図の 5 つの値の名前。min、q1、median、q3、max
min, max, ticksデータに合わせる、4軸の両端の値と目盛りの目安となる数。散布図の横軸には xMin、xMax、xTicks を使います
format, tickFormatロケールに従う値と目盛りの表示形式。散布図の横軸には xFormat を使います
currentなしaria-current が付くデータ点のインデックス

値表示、キー操作、凡例、色、目盛りは、どのグラフ形式でも共通です。すべてのオプション、CSS クラス、カスタムプロパティは チャート を参照してください。