I have a simple data to be plotted in a graph using python.
Tried doing that but somehow its not working. Please suggest.
x=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct']
y=[1,4,9,16,25,36,49,64,81,100]
tried to convert the x and y values to numpy array as well, but did not work.
getting the error: x and y must have same first dimension, but have shapes (10,) and (9,)
Please find the code as follows:
import matplotlib.pyplot as plt
import numpy as np
y=[1,4,9,16,25,36,49,64,81]
x=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct']
plt.title('monthwise sales')
plt.plot(x,y)
plt.xlabel('X axis')
plt.ylabel('y axis')
Your x and y arrays are of different lengths. Add plt.show()
at the end of the code to see the plot.
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.