Python matplotlib restrict to integer tick locations

后端 未结 3 1362
我寻月下人不归
我寻月下人不归 2020-11-29 11:15

Quite often I want to make a bar chart of counts. If the counts are low I often get major and/or minor tick locations that are not integers. How can I prevent this? It makes

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 11:35

     pylab.bar(range(1,4), range(1,4), align='center')  
    

    and

     xticks(range(1,40),range(1,40))
    

    has worked in my code. Just use the align optional parameter and xticks does the magic.

提交回复
热议问题