I am recently only trying to learn data analysis with python and am trying to use matplotlib for the first time. I am not sure what went wrong in my code but my y and x axis have 2 different ticks(?)
here is what I did:
plt.figure(figsize=(8,4))
plt.title('My Plot')
plt.subplot(1,2,1) # row, column, panel
plt.plot(x, x ** 2)
plt.plot([0,0,0],[-10,0,100]) #plot straight line, AT RANGE x 0,0,0 and y at -10-100
plt.legend(['x^2','Vertical Line']) #order by what plotted first
plt.xlabel('X')
plt.ylabel('X Squared')
and this is the results:
enter image description here
can anyone tell me whats wrong with the code? or what i can do to fix this?
I tried to use
plt.xticks(np.arange())
and plt.yticks(np.arange)
but nothing change
plt.minorticks_off()
<— also tried this code
Nom tumo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.