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.
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.
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:)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.