A stacked bar plot is a graphical representation of data in which the bars are divided into sections that represent the different components of the data. In Python, a stacked bar plot can be created using the Matplotlib library.
To create a stacked bar plot in Matplotlib, you will need to have NumPy and Matplotlib installed. To create a stacked bar plot in Python using Matplotlib, you can use the bar function and specify the bottom parameter to stack the bars on top of one another.
Some Python books to buy
1. https://amzn.to/3W5fsvv
2. https://www.amazon.in/Programming-Beg...
3.https://www.amazon.in/Doing-Math-Pyth...
4. https://www.amazon.in/NumPy-Data-Anal...
5. https://www.amazon.in/Data-Analysis-P...
6. https://www.amazon.in/Scipy-Numpy-Dev...
------------------------ Python Books----------------------------------------------------------------------
1. # https://amzn.to/3W5fsvv
2. https://www.amazon.in/Programming-Beg...
3.https://www.amazon.in/Doing-Math-Pyth...
4. https://www.amazon.in/NumPy-Data-Anal...
5. https://www.amazon.in/Data-Analysis-P...
6. https://www.amazon.in/Scipy-Numpy-Dev...
--------------------------------------CODE IS HERE---------------------------------------------
import libraries
%matplotlib widget
import numpy as np # for arrays
import matplotlib.pyplot as plt # for plotting
define x data
x =[' Sachin', 'Virat', 'Sehwag','Dhoni' ,'Gayle']
y1= np.array([463,265,245,350,301])# number of matched they played
y2= np.array([44.83,57.47,35.05,50.57,37.83]) # batting averge
y3= np.array([2016,1172,1132,820,1128]) # no of 4s
y4= np.array([195,127,136,229,331]) # no of 6s sixer
plt.bar(x,y1) # for no og matches
plt.bar(x,y2, bottom=y1,color='black') # for battimg average
plt.bar(x,y3,bottom=y1+y2) # no.of 4s
plt.bar(x,y4, bottom=y1+y2+y3) # no. of 6 sixer
plt.title('Stacked bar plot', color='red', fontsize=30,fontweight='bold')
plt.xlabel('Batsman', color='black', fontsize=30,fontweight='bold')
plt.ylabel('ODI Match', color='green', fontsize=30,fontweight='bold')
plt.legend([' Number of Matches', 'Batting Avg', ' Number:4- Fours', 'Number: 6-Sixer'])
plt.savefig('stackedbar.png', dpi=300)
In questa pagina del sito puoi guardare il video online BAR Plot| Python| STACKED BAR Plot For Beginners in Python della durata di ore minuti seconda in buona qualità , che l'utente ha caricato DESI ASTRO 06 gennaio 2023, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 64 volte e gli è piaciuto 3 spettatori. Buona visione!