In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to draw stacked bar chart by Python". In daily operation, I believe that many people have doubts about how to draw stacked bar chart by Python. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to draw stacked bar chart by Python". Next, please follow the editor to study!
Bar (xGradueHeightWidget 0.8) bottomized NoneParticipationaligninghewcenterpriseDataobleNoneweretickkeeper labelnNoneParticipityerrorNonePartioryerrornonewageNonerecoverykwargs)
The common parameters of this function are as follows:
X represents the coordinate value of x
Height: indicates the height of the column
Width: indicates the width of the column. Default is 0.8.
Bottom: represents the y coordinate value at the bottom of the column. The default is 0.
Align: indicates the alignment of a column, with values of 'center'' and 'edge', where' center' means to center the column with the tick mark, and 'edge'' means to align the left side of the column with the tick mark.
Tick_label: indicates the scale label corresponding to the column
Xerr,yerr: if it is not set to None, horizontal / vertical error bars need to be added to the bar chart
Error_kw: an attribute dictionary that represents an error bar. The keys of the dictionary correspond to the keyword parameters of the errorbar () function.
Example: stacked bar chart demonstration
Import matplotlib.pyplot as pltimport numpy as npx = np.arange (5) y1 = np.array ([10pyrus 8) y1 = np.array]) y2 = np.array ([9pyrus 6pyrus 5pyrus 10pyrus 12]) plt.bar (xmaike y1pagele = ['axiangliao pundles'], width=bar_width) plt.bar (xmemy2paramedy1parcels width) plt.show () example: stacking map with error stick
Import matplotlib.pyplot as plt import numpy as np x = np.arange (5) y1 = np.array ([10,8,7,11,13]) error = [2,1,2.5,2,1.5] bar_width = 0.3 # draw a bar graph plt.bar (x, y1, tick_label= ['a', 'baked,' cased, 'dumped,' e'] Width=bar_width) plt.bar (x, y1, bottom=y1, width=bar_width, yerr=error) plt.show () so far On the "Python how to draw stacked bar chart" study is over, I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.