Plot string values in matplotlib

后端 未结 5 2107
南旧
南旧 2020-12-06 02:17

I am using matplotlib for a graphing application. I am trying to create a graph which has strings as the X values. However, the using plot function expects a nu

5条回答
  •  被撕碎了的回忆
    2020-12-06 03:09

    You should try xticks

    import pylab
    
    names = ['anne','barbara','cathy']
    counts = [3230,2002,5456]
    
    pylab.figure(1)
    x = range(3)
    pylab.xticks(x, names)
    pylab.plot(x,counts,"g")
    
    pylab.show()
    

提交回复
热议问题