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

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -