-1

I am trying to plot a stacked bar chart on my data. I have data like this :

received_date :[ 2016-07-28,2016-10-10,2016-11-11,2016-12-09,2017-01-10]
null_count : [820145,1004174,1165932,1167409,1214356]   
total_count: [6356161,6344421,6428218,6405691,6409394]

Dates are from 2016-2022.

something like this

X axis : Dates grouped by years/months

Y axis : Count representing both null_count and total_count..

Been trying for 2 days now ...Any help would be very much appreciated.

1 Answers1

0
import matplotlib.pyplot as plt 
import numpy as np

received_date = [ '2016-07-28','2016-10-10','2016-11-11','2016-12-09','2017-01-10']
null_count =  np.array([820145,1004174,1165932,1167409,1214356])   
total_count = np.array([6356161,6344421,6428218,6405691,6409394])

plt.bar(received_date,null_count,color='b')
plt.bar(received_date,total_count,bottom=null_count,color='r')

plt.show()

Hope this helps :)

Abhay
  • 46
  • 4
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 14 '22 at 20:25