Hello, sorry, I'm new to Matplotlib and I have a problem. I have 2 queries to Mysql and I get 2 lists of data to graph with bars. The problem is that the second bar (red) should start at point 06 of the x axis and start at 01 with the other bar (green) I add the code of the consultations in the second the result starts in 06 because it is 0 the value of the other periods .. Many thanks
the graph has 2 bars of two queries but the red bar should start at point 06 of x not on 01
cursor2.execute("SELECT DATE_FORMAT(Fecha_Carga,'%m') as Fechas, ROUND(SUM(Cantidad_Litros),2) as Litros FROM tablaunion1 where YEAR(Fecha_Carga) = '2017' and Patente like '"+self.ui.PatenteText.text()+"%' Group by MONTH(Fecha_Carga)")
resultado2 = cursor2.fetchall()
i = 0
while i < len(resultado2):
#print(resultado3[i][0])
#print(resultado3[i][1])
dates2.append(resultado2[i][0])
values2.append(resultado2[i][1])
i= i+1
cursor2.close()
cursor3.execute("SELECT DATE_FORMAT(Fecha,'%m') as Fechas, ROUND(SUM(Kmrecorridos),2) as Km FROM usitrack where YEAR(Fecha) = '2017' and Patente like '"+self.ui.PatenteText.text()+"%' Group by MONTH(Fecha)")
resultado3 = cursor3.fetchall()
i = 0
while i < len(resultado3):
#print(resultado3[i][0])
#print(resultado3[i][1])
dates3.append(resultado3[i][0])
values3.append(resultado3[i][1])
i= i+1
#print(values3)
cursor3.close()
index3 = np.arange(len(dates3))
#dates3.append(row[0])
#values3.append(row[1])
bar_width = 0.35
opacity = 0.4
ngroups = 12
index = np.arange(ngroups)
#bar1 = plt.bar(index, values, bar_width, alpha=opacity, color='b',label = '2016')
bar2 = plt.bar(index,values2, bar_width, alpha=opacity, color='g',label = 'Litros')
bar3 = plt.bar(index3+bar_width, values3, bar_width , alpha=opacity, color='r',label = 'Km')
plt.xticks(index+bar_width, dates2 + dates3 , rotation= 30, size = 'small')
plt.legend(loc = "upper left",bbox_to_anchor=(1.0, 1.05), shadow=True)