![見出し画像](https://assets.st-note.com/production/uploads/images/66806912/rectangle_large_type_2_f4b4e444529557278d3622f453997ae9.png?width=1200)
[第6回] python-Highchartsを使ってみる
jupyter notebookとpythonを利用した分析講座となっております。
python-highcharts
ドリルダウンレポートを作成してみたく、jupyter notebookでpython-highchartsを使ってみます。
ラインチャート
from highcharts import Highchart
H = Highchart(width=300, height=300)
H.add_data_set([1, 2, 3])
H
![画像1](https://assets.st-note.com/production/uploads/images/66458644/picture_pc_62b87f77aeaa28bd29f2dae7a63bdbf8.png?width=1200)
X軸、Y軸などの設定
from highcharts import Highchart
H = Highchart(width=300, height=300)
H.set_options('title', {'text': 'メインタイトル'})
H.set_options('subtitle', {'text': 'サブタイトル'})
H.set_options('xAxis', {'title': {'text': 'X軸'}})
H.set_options('yAxis', {'title': {'text': 'Y軸'}, 'lineWidth': 2})
H.add_data_set([1, 2, 3])
H
![画像2](https://assets.st-note.com/production/uploads/images/66458701/picture_pc_aedb5d7ef6b20591609b1aac8c53d092.png?width=1200)
バーチャート+ラインチャート
from highcharts import Highchart
H = Highchart(width=300, height=400)
H.add_data_set([4, 5, 6], 'bar', 'data1')
H.add_data_set([3, 2, 5], 'line', 'data2')
H
![画像3](https://assets.st-note.com/production/uploads/images/66458745/picture_pc_2c166eb9a3467f14d55e38912cb273be.png?width=1200)
ドリルダウングラフ
※本来このように動くようですが私の環境では動きませんでした
![](https://assets.st-note.com/production/uploads/images/66843355/picture_pc_d5c03086b15cda592fc32fc6aecd79d2.gif)
from highcharts import Highchart
H = Highchart(width=400, height=300)
data = [{
'y': 1,
'drilldown': 'a'
}, {
'y': 2,
'drilldown': 'b'
}, {
'y': 3,
'drilldown': 'c'
}]
H.add_data_set(data, 'column')
H.add_drilldown_data_set([0.3, 0.4, 0.3], 'pie', 'a')
H.add_drilldown_data_set([4, 5, 6], 'line', 'b')
H.add_drilldown_data_set([7, 8, 9], 'area', 'c')
H
![画像4](https://assets.st-note.com/production/uploads/images/66458792/picture_pc_ca2cf99e492f8f8061c239996fe755a1.png?width=1200)