Last answered:

10 Apr 2023

Posted on:

09 Apr 2023

0

ValueError: x and y must have same first dimension, but have shapes (10,) and (11,)

Hello,

I have copied the code exactly as is but get error: ValueError: x and y must have same first dimension, but have shapes (10,) and (11,).

I also run each cell before I run the code:

plt.plot(x_axis,values)
plt.xlim(0,1.0)
plt.ylim(0,50)
plt.title('Our Plot')
plt.xlabel('This is the horizontal axis')
plt.ylabel('Vertical axis')
plt.show()

1 answers ( 0 marked as helpful)
Instructor
Posted on:

10 Apr 2023

0

Hey Lisa,


Thank you for reaching out!


The error tells you that the variables x_axis and values have different dimensions - the former is of length 10 and the latter -- of length 11. Revisit the definitions of both of these variables and run the code anew.


If the problem persists, please provide a screenshot of your code together with the error and the definition of these two variables.


Kind regards,

365 Hristina

Submit an answer