Python教程使用Chord包實(shí)現(xiàn)炫彩弦圖示例
首先來(lái)介紹一下什么是弦圖?
弦圖主要用于展示多個(gè)對(duì)象之間的關(guān)系,連接圓上任意兩點(diǎn)的線段叫做弦,弦(兩點(diǎn)之間的連線)就代表著兩者之間的關(guān)聯(lián)關(guān)系。
弦圖雖然看起來(lái)有點(diǎn)眼花繚亂,但是它卻非常適合用戶(hù)分析復(fù)雜數(shù)據(jù)的關(guān)聯(lián)關(guān)系。
Python中能夠繪制弦圖的包有一些,本篇主要介紹如何使用chord庫(kù)來(lái)制作酷炫的弦圖。可以查看官方文檔。
在使用前需要用pip安裝:
pip install chord
在官方文檔中很清晰地羅列了API的使用說(shuō)明,API分為free和pro兩個(gè)版本,其中pro版本在free的基礎(chǔ)上增加了不少新的參數(shù)可以使用,但是pro需要用戶(hù)支付一定的費(fèi)用,大概是10英鎊。
Free API:
Chord(self, matrix, names, colors="d3.schemeSet1", opacity=0.8, padding=0.01, width=700, label_color="#454545", wrap_labels=False, margin=0, credit=False, font_size="16px", font_size_large="20px" )
Pro API:
Chord(self, matrix, names, colors="d3.schemeSet1", opacity=0.8, padding=0.01, width=700, label_color="#454545", wrap_labels=False, margin=0, credit=False, font_size="16px", font_size_large="20px", details=[], details_thumbs=[], thumbs_width=85, thumbs_margin=5, thumbs_font_size=14, popup_width=350, noun="instances", details_separator=", ", divide=False, divide_idx=0, divide_size=0.5, instances=0, verb="occur together in", symmetric=True, title="", arc_numbers=False, divide_left_label="", divide_right_label="", inner_radius_scale=0.39, outer_radius_scale=1.1, allow_download=False, )
chord支持輸出html文件或者在Jupyter Lab中展示:
Chord(matrix, names).to_html()
Chord(matrix, names).show()
最后展示下使用chord畫(huà)圖的小例子,chord還支持交互操作,非??犰藕每?/p>


參考資料:
1.https://pypi.org/project/chord/
2.https://zhuanlan.zhihu.com/p/127134896
以上就是Python教程使用Chord包實(shí)現(xiàn)炫彩弦圖示例的詳細(xì)內(nèi)容,更多關(guān)于Chord包畫(huà)炫彩弦圖的資料請(qǐng)關(guān)注本站其它相關(guān)文章!
版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。
關(guān)注官方微信