In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to use python data visualization to make bar charts". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Preface
Matplotlib is a powerful 2D graphics drawing library of Python, which needs to be installed. By calling its internal function interface, you can cleanly generate histogram, pie chart, power spectrum, bar chart, error chart, scatter chart and so on.
Matplotlib installation.
Pip install matplotlib instance code
Cut the crap, it's all in the notes!
Import pandas as pdimport matplotlib.pyplot as mpl # introduces matplotlib library # to normally display Chinese tags mpl.rcParams ['font.sans-serif'] = [' SimHei'] # define x, y-axis list data buffer x _ axes= [] yaxes = [] # read table information sheet = pd.DataFrame (pd.read_excel ('mpl.xlsx')) # x and y-axis data Take the excel order number column and the quantity column x_axes = sheet ['order number'] y_axes = sheet ['quantity'] "1 line chart" mpl.plot " Label=' order quantity line chart') # set title and horizontal and vertical coordinate name mpl.title ('order number relation') mpl.xlabel (u 'order number') mpl.ylabel (u 'quantity') # display chart mpl.show () "" 2 bars "mpl.title ('order number relation') mpl.xlabel (u 'order number') mpl.ylabel (u 'quantity') mpl.bar Label=' order number quantity bar chart') # display chart mpl.show () "" 3 pie chart "# pie chart parameter x_num=sheet ['quantity'] labels= sheet ['order number'] explode= (0.1memo 0memo 0memo 0memo 0recover0) # draw a pie chart mpl.pie (x_num, # data labels=labels of the pie chart # the label explode=explode of each piece, # the number of pieces cut in the pie chart startangle=None, # is None or specify an angle If not None, rotate autopct='%1.2f%%' counterclockwise from x axis # 100% format, which is two decimal places mpl.axis ("equal") # change the limit of x or y axis so that the equal increments of x and y have the same length mpl.title ('single sign quantity relation') # pie chart title mpl.show () # display chart
The data in excel is as follows:
The bar chart is as follows:
This is the end of the content of "how to visually make a bar chart with python data". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.