Reputation: 1
I'm trying to combine 2 data into one graph but I'm unable to do so and keep getting a value error that X and Y must have the same first dimension. Is there any alternative way?
plt.figure(figsize = (10, 6))
X=np.arange(2009,2020)
Y=plt.plot(Total_Energy["Years"],Total_Energy['Households'])
fig, ax = plt.subplots()
ax.plot(X,greenhouse[' Total Greenhouse Gas Emissions (Gg CO2-equivalent) '])
ax.plot(X, Y)
ax.title('Total Greenhouse Gas Emissions (Gg CO2-equivalent) ')
ax.ylabel('Gas Emission')
ax.xlabel('Households Energy Consumption')
plt.show()
Upvotes: 0
Views: 89
Reputation: 11
It seems that the length of/the number of records in Y is around 100 but length of X is around 10.assuming X is the year and you want to plot a graph about gas emissions over time you need to get only last 12 items in Y, assuming the last item in Y is the gas emissions in year 2020.a simple solution is Y = Y[-12:] since the length of X is 12.
Upvotes: 1