Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to draw a column chart with Python

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to use Python to draw a column chart", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use Python to draw a column chart"!

Bar = (Bar () .add _ xaxis (x_vals) .add _ yaxis ("Guangzhou stores", [random.randint (10,100) for _ in range (6)]) .add _ yaxis ("Zhongshan stores", [random.randint (10,100) for _ in range (6)]) .add _ yaxis ("Shenzhen stores", [random.randint (10,100) for _ in range (6)]) .add _ yaxis ("Dongguan stores") [random.randint (10,100) for _ in range (6)] .set _ series_opts (label_opts=opts.LabelOpts (is_show=True, font_size=14), markline_opts=opts.MarkLineOpts (data= [opts.MarkLineItem (yearly 40, name= "line of attainment = 40")) .set _ global_opts (title_opts=opts.TitleOpts (title=' actual sales amount', subtitle= "QDM") Xaxis_opts=opts.AxisOpts (name=' goods'), yaxis_opts=opts.AxisOpts (name=' units: ten thousand yuan')) # bar.render ('bar chart .html') # or bar.render_notebook ()

Render effect:

Goods = ["vegetables", "fruit", "pork", "e-commerce", "comprehensive", "aquatic products"] bar = (Bar () .add _ xaxis (goods) .add _ yaxis ('supplier Agar, [random.randint (10,100) for _ in range (6)], stack='stack1') .add _ yaxis (' supplier Baker, [random.randint (10,100) for _ in range (6)] Stack='stack1') .add _ yaxis ('supplier clients, [random.randint (10,100) for _ in range (6)], stack='stack1') .set _ series_opts (label_opts=opts.LabelOpts (is_show=False)) .set _ global_opts (title_opts=opts.TitleOpts (title= "actual sales quantity"), xaxis_opts=opts.AxisOpts (name= "category") Yaxis_opts=opts.AxisOpts (name= "sales volume (unit: unit)") # bar.render ('columnar stack chart .html') # or bar.render_notebook ()

Render effect:

# Bar chart x_vals1 = ["White Pomfret", "Little Oyster", "saury", "Spring Fish", "South Pomfret", "Sea Sanbao"] x_vals2 = ["Silver Fish", "Shrimp", "Sand Carp", "Mud fierce", "abalone"] x_vals3 = ["crucian carp", "Wuchang fish", "white flower fish", "sea bass", "eyebrow grass carp" "Aconitum"] # change the simulated random number into a list form And in ascending order, y_vals = [1 x_vals1 2 x_vals2 3 4 5, 6 7, 8 9, 10 11, 13 15 16 18] bar = Bar (). Add_xaxis (x_vals1 + x_vals2 + x_vals3) bar.add_yaxis ("quality control discount acceptance item", y_vals, markpoint_opts=opts.MarkPointOpts (data= [opts.MarkPointItem (type_='average'), opts.MarkPointItem (type_='max')) Opts.MarkPointItem (type_='min')], symbol_size=80)) bar.set_series_opts (label_opts=opts.LabelOpts (is_show=True) Position= "right") # items are more attractive than bars bar.set_global_opts (title_opts=opts.TitleOpts (title= "number of discounted items", subtitle= "mail")) bar.reversal_axis () # Flip the XY axis Convert a bar chart to a bar chart # bar.render ('bar chart .html') # or bar.render_notebook ()

Render effect:

# Bar chart # merge three lists into one list-> Ctrl+H, Windows+10, "," > needed in Excel

Render effect:

# Bar chart (pure version) # merge three lists into one list-> Ctrl+H and Windows+10 in Excel Keyboard shortcut x_vals1 = ["White Pomfret", "Little Oyster", "saury", "Spring Fish", "South Pomfret", "Sea Sanbao", "Silver Fish", "Kei Wai Shrimp", "Sand Carp", "Mud fierce", "abalone", "Carassius auratus", "Wuchang Fish", "White Flower Fish", "Sea perch", "eyebrow Grass Carp" "Aconitum"] # change the simulated random number into a list form In ascending order, y_vals = [1 x_vals1 2, 3 4, 5 5, 6, 7, 8, 9, 10, 11, 13, 15, 15, 17, 18] bar = Bar (). Add_xaxis (x_vals1) bar.add_yaxis ("quality control discount acceptance item", y_vals,) bar.set_series_opts (label_opts=opts.LabelOpts (is_show=True) Position= "right") # items are more attractive than bars bar.set_global_opts (title_opts=opts.TitleOpts (title= "number of discounted items", subtitle= "mail")) bar.reversal_axis () # Flip the XY axis Convert a bar chart to a bar chart # bar.render ('bar chart .html') # or bar.render_notebook ()

Render effect:

Thank you for your reading, the above is the content of "how to draw a column chart with Python". After the study of this article, I believe you have a deeper understanding of how to draw a column chart with Python, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report