Python matplotlib - setting x-axis scale -


i have graph displaying following:

plt.plot(valuex, scorelist) plt.xlabel("score number") # text x-axis plt.ylabel("score") # text y-axis plt.title("scores topic "+progressdisplay.topicname) plt.show() 

valuex = [1, 2, 3, 4] , scorelist = [5, 0, 0, 2]

i want scale go in 1's, no matter values in 'scorelist'. x-axis going in .5 instead of 1s.

how set goes in 1?

just set xticks yourself.

plt.xticks([1,2,3,4]) 

or

plt.xticks(valuex) 

since range functions happens work integers use instead:

plt.xticks(range(1, 5)) 

or more dynamic , calculate data:

plt.xticks(range(min(valuex), max(valuex)+1)) 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -