Get the App
SLTechnology News&Howtos  ›  Development  › 

How to draw stacked column Chart by Python

Shulou Source: shulou.com Published: 2022-06-03 13:22:36 09月17日 Update

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!

Tags: Error learning scale function parameter dictionary more scalar example help practical next two keyword width attribute commonly used bottom article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Docker Shulou Tech Info Redmi MySQL