您好,登錄后才能下訂單哦!
這篇文章主要介紹“如何用cutecharts庫繪制手繪風格的可視化圖形”,在日常操作中,相信很多人在如何用cutecharts庫繪制手繪風格的可視化圖形問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”如何用cutecharts庫繪制手繪風格的可視化圖形”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
# 導入相關的庫 import cutecharts.charts as ctc import pandas as pd from cutecharts.components import Page # 構造數據 df = pd.DataFrame({ "x":["蔬菜", "水果", "水產", "豬肉", "零食", "電商", "物料"], "y":[100, 130, 169, 220, 286, 372, 484], "z":[20, 26, 34, 44, 57, 74, 96]})
1. 柱形圖
chart = ctc.Bar("各品類的銷售業績", width = "500px", height = "400px") chart.set_options(labels = list(df["x"]), x_label ="部門", y_label= "銷售額(萬元)", colors = ["#1EAFAE" for i in range(len(df))] ) chart.add_series("2020年",list(df["y"])) chart.render_notebook()
1.1 自定義各根柱子的顏色
chart = ctc.Bar("各品類的銷售業績", width = "500px", height = "400px") chart.set_options(labels=list(df["x"]), x_label = "2020年", y_label = "銷售額(萬元)", colors = ["yellow","orange","pink","red","purple","green","blue"] ) chart.add_series("2020年",list(df["y"])) chart.render_notebook()
渲染效果:
2. 折線圖
chart = ctc.Line("各品類的銷售業績",width = "500px", height = "400px") chart.set_options(labels = list(df["x"]), x_label ="2020年環比2019年", y_label = "銷售額(萬元)" ) chart.add_series("今年", list(df["y"])) chart.add_series("去年", list(df["z"])) chart.render_notebook()
3. 雷達圖
chart = ctc.Radar("各品類的銷售業績",width = "700px", height = "600px") chart.set_options(labels=list(df["x"]), is_show_legend = True, #by default, it is true. You can turn it off. legend_pos = "upRight" #location of the legend ) chart.add_series("2020年",list(df["y"])) chart.add_series("2019年",list(df["z"])) chart.render_notebook()
4. 餅圖
chart = ctc.Pie("各品類銷售業績占比",width ="500px",height = "400px") chart.set_options(labels=list(df["x"]),inner_radius=0) chart.add_series(list(df["y"])) chart.render_notebook()
5. 環形圖
chart = ctc.Pie("各品類銷售業績占比",width ="500px",height = "400px") chart.set_options(labels=list(df["x"]),inner_radius=0.6) chart.add_series(list(df["y"])) chart.render_notebook()
6. 散點圖
# 再構造一組數據 amount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] sales = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]
chart = ctc.Scatter("某種定價商品的銷售額與銷售量之間的關系",width= "500px",height = "600px") chart.set_options(x_label = "銷售數量(件)", y_label = "銷售額(元)", colors=["#1EAFAE"], is_show_line = False, dot_size = 1) chart.add_series("進口香印青提", [(z[0], z[1]) for z in zip(amount, sales)]) chart.render_notebook()
7. 組合圖
chart1 = ctc.Line("各品類的銷售業績",width ="500px",height ="400px") chart1.set_options(labels=list(df["x"]), x_label = "品類",y_label = "銷售額(萬元)" ) chart1.add_series("2020年", list(df["y"])) chart1.add_series("2019年", list(df["z"])) chart2 = ctc.Bar("各品類的銷售業績",width = "500px",height = "400px") chart2.set_options(labels=list(df["x"]),x_label = "品類", y_label = "銷售額(萬元)" ,colors=["#1EAFAE" for i in range(len(df))]) chart2.add_series("2020年", list(df["y"])) chart2.add_series("2019年", list(df["z"])) page = Page() page.add(chart1, chart2) page.render_notebook()
到此,關于“如何用cutecharts庫繪制手繪風格的可視化圖形”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。